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
96c2ec060f70a8e9139ce63b70641cb1ab6e8511
3a4fbde06794da1ec4c778055dcc5586eec4b7d2
/SQLAlchemy-0.5.4p2/examples/elementtree/pickle.py
220bb2295386a75a1311c597f76514c078ad8ffb
[ "MIT" ]
permissive
raychorn/svn_python-django-projects
27b3f367303d6254af55c645ea003276a5807798
df0d90c72d482b8a1e1b87e484d7ad991248ecc8
refs/heads/main
2022-12-30T20:36:25.884400
2020-10-15T21:52:32
2020-10-15T21:52:32
304,455,211
0
0
null
null
null
null
UTF-8
Python
false
false
2,018
py
"""illustrates a quick and dirty way to persist an XML document expressed using ElementTree and pickle. This is a trivial example using PickleType to marshal/unmarshal the ElementTree document into a binary column. Compare to explicit.py which stores the individual components of the ElementTree structure in distinct rows using two additional mapped entities. Note that the usage of both styles of persistence are identical, as is the structure of the main Document class. """ from sqlalchemy import (create_engine, MetaData, Table, Column, Integer, String, PickleType) from sqlalchemy.orm import mapper, create_session import sys, os import logging logging.basicConfig() # uncomment to show SQL statements #logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO) # uncomment to show SQL statements and result sets #logging.getLogger('sqlalchemy.engine').setLevel(logging.DEBUG) from xml.etree import ElementTree engine = create_engine('sqlite://') meta = MetaData(engine) # stores a top level record of an XML document. # the "element" column will store the ElementTree document as a BLOB. documents = Table('documents', meta, Column('document_id', Integer, primary_key=True), Column('filename', String(30), unique=True), Column('element', PickleType) ) meta.create_all() # our document class. contains a string name, # and the ElementTree root element. class Document(object): def __init__(self, name, element): self.filename = name self.element = element # setup mapper. mapper(Document, documents) ###### time to test ! ######### # get ElementTree document filename = os.path.join(os.path.dirname(__file__), "test.xml") doc = ElementTree.parse(filename) # save to DB session = create_session() session.add(Document("test.xml", doc)) session.flush() # clear session (to illustrate a full load), restore session.expunge_all() document = session.query(Document).filter_by(filename="test.xml").first() # print document.element.write(sys.stdout)
[ "raychorn@gmail.com" ]
raychorn@gmail.com
819c2a0bc256c3c24169c4a6e29f6731b02f8ea4
a56a92b18e423f66db497ac905b02b08eb1c040a
/solutions/sortcolours.py
e20ada97aeab0e5a7749523f728ef8d35a65a6e3
[]
no_license
DeepakSunwal/Daily-Interview-Pro
12294218a1e5a5e522ad2c491ca00e39581efdfc
1a9a9a0e1116eda854132164051086d9b0386184
refs/heads/master
2021-01-02T10:01:23.356507
2020-01-31T17:18:23
2020-01-31T17:18:23
239,569,007
1
0
null
2020-02-10T17:18:49
2020-02-10T17:18:48
null
UTF-8
Python
false
false
1,073
py
def sort_colours(colours): left = 0 right = len(colours) - 1 while left < right: if colours[left] != 0 and colours[right] == 0: temp = colours[right] colours[right] = colours[left] colours[left] = temp else: if colours[right] != 0: right -= 1 if colours[left] == 0: left += 1 right = len(colours) - 1 while left < right: print(colours) print(colours[left], colours[right]) if colours[left] != 1 and colours[right] == 1: temp = colours[right] colours[right] = colours[left] colours[left] = temp else: if colours[right] != 1: right -= 1 if colours[left] == 1: left += 1 return colours def main(): assert sort_colours([2, 0, 2, 1, 1, 0]) == [0, 0, 1, 1, 2, 2] assert sort_colours([0, 1, 2, 2, 1, 1, 2, 2, 0, 0, 0, 0, 2, 1]) == [0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2] if __name__ == '__main__': main()
[ "ckallumke@gmail.com" ]
ckallumke@gmail.com
93dab1bd92832266e305366a0e12cb2522e07b4b
d5a6ad0eabe229f025f7852f57331c0c464b21fd
/8-16.py
b2c06fdb42802a730dff0a6df846e031f8534e6f
[]
no_license
t4kenn/python
6bb7462a6e1a156b1c63c9e697c7e04f2b4445f5
fb269671301761454916eaf7b9979a120e112c1c
refs/heads/master
2023-08-11T01:34:07.468003
2021-09-22T00:52:23
2021-09-22T00:52:23
409,018,151
0
0
null
null
null
null
UTF-8
Python
false
false
131
py
n = {"id" : 100,"name" : "大原太郎", "age" : 19} n["age"] = 20 for key,value in n.items(): print(key, ":", value, sep="")
[ "ykh2135151@stu.o-hara.ac.jp" ]
ykh2135151@stu.o-hara.ac.jp
331e61ff53942c28609b93239ce7dbf1b4c43c37
385c6e5e1b3a00217a21ae1ea10edea470e8a295
/recommendSystem/calculate.py
831488c4c21852d453bd576952710970eae759f3
[]
no_license
13690842809/recommendSystem
13966d6b278e59ed0fde055c2c627b7d38cfbc92
86335af50db4d7b4a7b1ff492fc0d016e17ffe8b
refs/heads/master
2021-01-19T21:41:37.415934
2017-04-19T02:26:25
2017-04-19T02:26:25
88,690,397
0
0
null
null
null
null
UTF-8
Python
false
false
120
py
# for i in range(1,30+1): # print(float(30/i),round(30/i),round(30/i)*i) import random print(random.randint(1,100))
[ "noreply@github.com" ]
13690842809.noreply@github.com
b56e089475355cab6b64ed77bf9bceac0283dd6d
5f9f9ce3c08f7faf5ff97d17290e71460b9ca4e2
/bin/bigpanda-splunk-configure
1494c13d518aac970d589cf64275327848d9ace0
[ "Apache-2.0" ]
permissive
bigpandaio/bigpanda-splunk
844b18ddbdede1916c5cb15fc7dcb4d54cbebc3f
0af83f6512de32e6694621c8ad0590e634010496
refs/heads/master
2023-04-13T05:59:51.012346
2014-11-05T07:50:14
2014-11-05T07:50:14
23,677,756
0
2
Apache-2.0
2023-03-31T19:09:14
2014-09-04T20:14:06
Python
UTF-8
Python
false
false
149
#!/usr/bin/env python from bigpanda_splunk.configure import configure import os import sys configure(os.path.join(os.getcwd(), __file__), sys.argv)
[ "erik.zaadi@gmail.com" ]
erik.zaadi@gmail.com
be8452da0024401064e68544eae38b8f503edbb3
88a9d5c504d422bb46dbdec762bbfce444b4df92
/django_movie/movies/migrations/0002_alter_rating_movie.py
4bd9097962b09f9db7a2e81ce3dcab77bcf7a494
[]
no_license
Siberian87/Movie_site
cde676935f810741fec6185725cf5f7775c21e98
02f80e4e8654b90c89b7004fb4c5fa61d0479eed
refs/heads/main
2023-06-14T13:52:47.338854
2021-06-18T10:44:04
2021-06-18T10:44:04
376,953,885
0
0
null
null
null
null
UTF-8
Python
false
false
483
py
# Generated by Django 3.2.4 on 2021-06-15 09:10 from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ ('movies', '0001_initial'), ] operations = [ migrations.AlterField( model_name='rating', name='movie', field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='movies.movie', verbose_name='фильм'), ), ]
[ "user@MacBook-Pro-user.local" ]
user@MacBook-Pro-user.local
9f0388331526b033176eee3a7140c7ffb19dae0e
e04f721d9b0a98a30fb51e8cf9bfdc1fd827c488
/internado/wsgi.py
46a0b8ba6ac3d5949bbbee4139d1e186ef274075
[]
no_license
AustinCheco/Mi_prueba_Django
df5f9ef1e0f9706e7129a10046c0325592a55eeb
9bc3478c282d298e63998bb093a206747b94faf1
refs/heads/master
2021-06-18T08:31:21.146461
2019-07-13T22:56:08
2019-07-13T22:56:08
196,772,225
0
0
null
2021-06-10T21:42:42
2019-07-13T22:38:55
Python
UTF-8
Python
false
false
395
py
""" WSGI config for internado 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.9/howto/deployment/wsgi/ """ import os from django.core.wsgi import get_wsgi_application os.environ.setdefault("DJANGO_SETTINGS_MODULE", "internado.settings") application = get_wsgi_application()
[ "austincuyocheco@gmail.com" ]
austincuyocheco@gmail.com
b151e03e134c5c2e80bc00d06b6ca7c43b4654c6
980699f2c1621cd1752b5db38e68916e17161754
/mediamedianaemoda.py
1e9d5ee3f4aa7ec21c6970e3a9400a05e790884a
[]
no_license
caiooliveirac/estatistica
079a7ae195740ae8f4eeefc1d782c32487a213f8
96406d514f8cbd9c6d5b1a676b3e3d267466b8e7
refs/heads/main
2023-06-22T11:11:06.499029
2021-07-23T16:46:09
2021-07-23T16:46:09
388,826,976
0
0
null
null
null
null
UTF-8
Python
false
false
582
py
arr = list(map(int,input().rstrip().split(' '))) def media(): media = sum(arr)/len(arr) return media def mediana(): if len(arr) % 2 == 0: elem1 = sorted(arr)[len(arr)//2] elem2 = sorted(arr)[(len(arr)//2)-1] return (elem1 + elem2)/2 else: mediana = sorted(arr)[len(arr)//2] return mediana def moda(): return max(arr,key=arr.count) def stats(): a = media() b= mediana() c = moda() print(round(a,2)) print(round(b,2)) print(c) if __name__ == '__main__': stats()
[ "noreply@github.com" ]
caiooliveirac.noreply@github.com
44b84ed057f077bfb51dc248dfe04fe9858db108
53e7b46d2928b95105c8c5330ebf434e49731575
/qn1.py
0a5b2903373dd073443004097c038d89c9413935
[]
no_license
Sujankhyaju/Trainee_python_Assignment
3ef46992b136031fc837e01accb677a02852139b
7fea51ba7f4b71da6999c96f4e28a59fa7480a64
refs/heads/master
2023-08-11T11:58:49.582905
2021-09-10T12:05:50
2021-09-10T12:05:50
404,970,110
1
0
null
null
null
null
UTF-8
Python
false
false
713
py
# Make a list of ten students in your class. Print the name of each student whose name starts with ‘B’. def filterStudents(list1): ''' shows the name of student whose name starts with 'B' ''' for name in list1: if ord(name[0]) == 66: #checks if the name starts with 'B'. Asci value of B is 66 and b is 98 print(name) def registerStudent(): ''' take names of students ''' std = list() print("Enter name of 10 students in your class\n") for i in range(1,11): name = input(f"{i} -->") std.append(name) return std def main(): std = registerStudent() filterStudents(std) if __name__ == '__main__': main()
[ "I33489@verisk.com" ]
I33489@verisk.com
8cf28e90d2bcbd1f81c169d76168147071d9e225
51b838412b7d9d38e398fefff92a0f17b3e040d7
/enso/enso/contrib/scriptotron/ensoapi.py
a4cb12b67d501d86a9a521f683ec1550f48cd65d
[ "BSD-2-Clause" ]
permissive
thdoan/enso-portable
ed87bb30f3fe5d95e8dc6f3c4fa2a1a3a46f37fc
2dd6db78f40811d78fe9a162ec95eac14bda2250
refs/heads/master
2020-04-05T19:01:50.058547
2015-01-11T16:46:56
2015-01-11T16:46:56
28,119,291
8
5
null
null
null
null
UTF-8
Python
false
false
1,922
py
import xml.sax.saxutils from enso.messages import displayMessage from enso import selection class EnsoApi(object): """ A simple facade to Enso's functionality for use by commands. """ def display_message(self, msg, caption=None): """ Displays the given message, with an optional caption. Both parameters should be unicode strings. """ if not isinstance(msg, basestring): msg = unicode(msg) msg = xml.sax.saxutils.escape(msg) xmltext = "<p>%s</p>" % msg if caption: caption = xml.sax.saxutils.escape(caption) xmltext += "<caption>%s</caption>" % caption return displayMessage(xmltext) def get_selection(self): """ Retrieves the current selection and returns it as a selection dictionary. """ return selection.get() def set_selection(self, seldict): """ Sets the current selection to the contents of the given selection dictionary. Alternatively, if a string is provided instead of a dictionary, the current selection is set to the unicode contents of the string. """ if isinstance(seldict, basestring): seldict = { "text" : unicode(seldict) } return selection.set(seldict) def get_enso_commands_folder(self): """ Returns the location of the Enso scripts folder. """ from enso.providers import getInterface return getInterface("scripts_folder")() def get_commands_from_text(self, text): """ Given a block of Python text, returns all the valid Enso commands defined therein. """ from cmdretriever import getCommandsFromObjects execGlobals = {} exec text in execGlobals commands = getCommandsFromObjects( execGlobals ) return commands
[ "gchristnsn@gmail.com" ]
gchristnsn@gmail.com
e3ea75eec250197dd030f88d7bb8fdb47807bab0
eb9f655206c43c12b497c667ba56a0d358b6bc3a
/python/testData/refactoring/rename/renameUpdatesImportReferences/before/a.py
990c241c88d830934b115f98f771d048a07c4652
[ "Apache-2.0" ]
permissive
JetBrains/intellij-community
2ed226e200ecc17c037dcddd4a006de56cd43941
05dbd4575d01a213f3f4d69aa4968473f2536142
refs/heads/master
2023-09-03T17:06:37.560889
2023-09-03T11:51:00
2023-09-03T12:12:27
2,489,216
16,288
6,635
Apache-2.0
2023-09-12T07:41:58
2011-09-30T13:33:05
null
UTF-8
Python
false
false
17
py
import f<caret>oo
[ "andrey.vlasovskikh@jetbrains.com" ]
andrey.vlasovskikh@jetbrains.com
251bae5aaf32ca72cd850246ab648153d3a872dc
2a1d7cef10bd4d030e7f05c2eee342099ee3affa
/lecture13PloyMorphism-part2.py
81a16f096738948cd40a77834aac16adaeb71f82
[]
no_license
mohd-tanveer/PythonAdvance
8dc096edc75975eaa44af005c691aa15428c9254
dd4ac13a7b59cee33f94fcb5c88f52f3ffc0a6ae
refs/heads/master
2022-11-18T21:05:11.547842
2020-07-20T06:38:14
2020-07-20T06:38:14
273,145,823
0
0
null
null
null
null
UTF-8
Python
false
false
2,715
py
##polymorphism-2 #Operator overloading 2 #let's try to print the object class Book: def __init__(self,pages): self.pages=pages b1=Book(100) ''' output : main<>.object at x0246036 class Book: def __init__(self,pages): self.pages=pages def __str__(self): return('the number of pages :'+str(self.pages)) ##both should of of string type for concatenation #it is used just as print purpose of type string #def __add__(self,other): # self.pages+other.pages def __add__(self,other): total=self.pages+other.pages b=Book(total) return b #Similarly we can use __mul__ and other operator def __mul__(self,other): total=self.pages+other.pages b=Book(total) return b b1=Book(100) print(b1)##it will call __str__ b2=Book(200) print(b1+b2)#it will call __add__ b3=Book(300) print(b1+b2+b3)# output will be unsupported(b1+b2) is int type and B3 is Book Type , to overcome this let's modify __add__ #now the output will be 300 with return type as Book ---600 b4=Book(700) print(b1+b2+b3+b4)## now we can add as many as possible ''' Whenever we are calling + operator then __add__() method will be called whenever er are printing object reference then __str__() method will be called ''' print(b1+b2*b3+b4) #the output will be: the number of pages:60700 ##example 2 class Student: def __init__(self,name,marks): self.name=name slef.marks=name def __lt__(self,other): self.marks<other.marks s1= Student('durga',100) s2= Student('Sabi',200) print(s1<s2) #we want to compare the marks of student. ##example 3 class Employee: def __init__(self,name,salary): self.name=salary slef.salary=salary def __mul__(self,other): return self.salary*other.days class TimeSheet: def __init__(self,name,days): self.name=name self.days=days def __mul__(self,other): self.days*other.salary e=Employee('tanv',800) t=TimeSheet('tanv',25) print('this months salary is',e*t) print('this months salary :'t*e) #to work this we need to define the __mul__ in Timehseet ############ Method Overloading ############# #################################################### # same name of method but different argument types # but in python we never define the argument type hence python does not support Method Overloading # However if we write method overloading last method will be called everytime #example class Test: def m1(self): print('no-arg method): def m1(self,x): print('no-arg method): t=test()#it will not work because as soon as we decalre the second method with the same name first method gone t=test(11)#it will work #let's discuss alternate method in next class
[ "noreply@github.com" ]
mohd-tanveer.noreply@github.com
d0829958bc123518a9020ef7a50424eb6c3cf05c
77ab53380f74c33bb3aacee8effc0e186b63c3d6
/5356_luck_number_in_matrix.py
e3e46bb57b5d7ef93ba3454821dad28f4b2981fd
[]
no_license
tabletenniser/leetcode
8e3aa1b4df1b79364eb5ca3a97db57e0371250b6
d3ebbfe2e4ab87d5b44bc534984dfa453e34efbd
refs/heads/master
2023-02-23T18:14:31.577455
2023-02-06T07:09:54
2023-02-06T07:09:54
94,496,986
2
0
null
null
null
null
UTF-8
Python
false
false
1,288
py
''' Given a m * n matrix of distinct numbers, return all lucky numbers in the matrix in any order. A lucky number is an element of the matrix such that it is the minimum element in its row and maximum in its column. Example 1: Input: matrix = [[3,7,8],[9,11,13],[15,16,17]] Output: [15] Explanation: 15 is the only lucky number since it is the minimum in its row and the maximum in its column Example 2: Input: matrix = [[1,10,4,2],[9,3,8,7],[15,16,17,12]] Output: [12] Explanation: 12 is the only lucky number since it is the minimum in its row and the maximum in its column. Example 3: Input: matrix = [[7,8],[1,2]] Output: [7] Constraints: m == mat.length n == mat[i].length 1 <= n, m <= 50 1 <= matrix[i][j] <= 10^5. All elements in the matrix are distinct. ''' class Solution(object): def luckyNumbers(self, matrix): min_nums_in_rows = set() max_nums_in_cols = set() for row in matrix: min_nums_in_rows.add(min(row)) for i in range(len(matrix[0])): col = [matrix[j][i] for j in range(len(matrix))] max_nums_in_cols.add(max(col)) result = min_nums_in_rows.intersection(max_nums_in_cols) return list(result) s = Solution() m = [[3,7,8],[9,11,13],[15,16,17]] print(s.luckyNumbers(m))
[ "tabletenniser@gmail.com" ]
tabletenniser@gmail.com
79fceff98271d886941b8b4cb590ee0b73f4764f
788708a52401cb7e482ecc4758f19a53739c3c8c
/codeforces/cf_550/b.py
99486a8eb169bbd67ff4baa999d2faa5e982ac9e
[]
no_license
gsravank/ds-algo
9e8c55ada485547b3452e17ff10660328f0cd28f
818198126db3aa40d0bf096ad462b5293d1e29c9
refs/heads/master
2020-04-21T16:58:38.324009
2019-05-30T15:31:28
2019-05-30T15:31:28
169,720,677
0
0
null
null
null
null
UTF-8
Python
false
false
694
py
import heapq n = int(input()) a = list(map(int, input().split())) parity_map = {0: [], 1: []} for ai in a: parity_map[ai % 2].append(ai) odd_len = len(parity_map[1]) even_len = len(parity_map[0]) min_heap = list() if abs(odd_len - even_len) <= 1: print(0) else: if odd_len > even_len: rem_len = odd_len - even_len - 1 rel_elems = parity_map[1] else: rem_len = even_len - odd_len - 1 rel_elems = parity_map[0] heapq.heapify(rel_elems) # print(rel_elems) ans = 0 for _ in range(rem_len): curr = heapq.heappop(rel_elems) ans += curr print(ans) # print(rel_elems) """ 10 2 1 3 5 7 9 11 13 15 17 """
[ "kumarsravangs@gmail.com" ]
kumarsravangs@gmail.com
dc883bb6c8566a1cca492ac09213b898f330f17e
443cdd946b638fcbf97f249e8a887e7eba30a8d1
/Allocation/urls.py
1f35604ea603236f7f2dd9a00bcc63bb53ffe378
[]
no_license
ilyashumilov/Alllocation
eb22222a68fde67c0c6df54f9dd65e62b6e1b4ee
16e02414d50dd1a47a1cf5347e8699dd118c1965
refs/heads/main
2023-08-10T21:14:41.635891
2021-09-19T08:51:09
2021-09-19T08:51:09
408,074,749
0
0
null
null
null
null
UTF-8
Python
false
false
797
py
"""Allocation URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/3.2/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: path('', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin from django.urls import path, include urlpatterns = [ path('', include('base.urls')), path('admin/', admin.site.urls), ]
[ "ilya.sadventure@gmail.com" ]
ilya.sadventure@gmail.com
3d529053e7cb746231380c2095b4842ba4f50f7c
a81c057d388bac914a4cd8c714dd13e298f28d94
/Problem 3.py
452c5d5cbd1f958e904fad90ec48910e474e8563
[]
no_license
AvijitMaity/Avijit-Maity-Computational-Physics-2-Assignment-2
8a575c3eafe5db84af2520276f21df25bb5e3e3b
325dfc6a8e5587e727dc1dc74dc133f5e956bb64
refs/heads/master
2022-04-22T18:19:35.109350
2020-04-21T08:12:26
2020-04-21T08:12:26
257,411,319
0
0
null
null
null
null
UTF-8
Python
false
false
1,891
py
''' Runge-Kutta Method ==================================================================== Author: Avijit Maity ==================================================================== This Program solves the differential equation using with Runge-Kutta Method ''' import numpy as np import matplotlib.pyplot as plt from scipy.integrate import odeint # The ordinary differential equation def f(x,y,z ): return z def g(x,y,z ): return 2*z - y + x*np.exp(x) - x # Define the initial values and mesh # limits: 0.0 <= x <= 1.0 a=0 b=1 h= 0.01 # determine step-size x = np.arange( a, b+h, h ) # create mesh N = int((b-a)/h) y = np.zeros((N+1,)) # initialize y z = np.zeros((N+1,)) # initialize z x[0]=0 y[0]=0 z[0]=0 for i in range(1,N+1): # Apply Runge-Kutta Method k1 = h * f(x[i - 1], y[i - 1], z[i - 1]) l1 = h * g(x[i - 1], y[i - 1], z[i - 1]) k2 = h * f(x[i - 1] + h / 2.0, y[i - 1] + k1 / 2.0, z[i - 1] + l1 / 2.0 ) l2 = h * g(x[i - 1] + h / 2.0, y[i - 1] + k1 / 2.0, z[i - 1] + l1 / 2.0 ) k3 = h * f(x[i - 1] + h / 2.0, y[i - 1] + k2 / 2.0, z[i - 1] + l2 / 2.0) l3 = h * g(x[i - 1] + h / 2.0, y[i - 1] + k2 / 2.0, z[i - 1] + l2 / 2.0) k4 = h * f(x[i-1]+h, y[i - 1] + k3, z[i - 1] + l3) l4 = h * g(x[i-1]+h, y[i - 1] + k3, z[i - 1] + l3) y[i] = y[i - 1] + (k1 + 2.0 * k2 + 2.0 * k3 + k4) / 6.0 z[i] = z[i - 1] + (l1 + 2.0 * l2 + 2.0 * l3 + l4) / 6.0 # The exact solution for this initial value def exact( x ): return (-12 + 12*np.exp(x) - 6*x - 6*np.exp(x)*x + np.exp(x)*x**3)/6 # Plot the Euler solution from matplotlib.pyplot import * plot( x, y, label='approximation' ) plot( x, exact(x),":",color="red",label='exact' ) title( "Runge-Kutta Method in a Python, h= 0.01" ) suptitle("Problem 3") xlabel('x') ylabel('y(x)') legend(loc=4) grid() show()
[ "noreply@github.com" ]
AvijitMaity.noreply@github.com
17cd4aa09c704d7ca398950c4f83f73c92897f8b
0991fb3056fefb8cb3c380e37e42a305e5810b2a
/catalog/models.py
b73117367fc4bf68704457812fedce19269b61e3
[]
no_license
uyencfi/integrated-library-system
c6827bbe6c07967a6f059aea64f18f73fb52179e
f4e2fd24ec35a27f5dab9aeae5b98370c42b9f88
refs/heads/master
2023-03-29T03:29:03.768148
2021-03-30T13:35:27
2021-03-30T13:35:27
342,171,939
0
0
null
null
null
null
UTF-8
Python
false
false
3,754
py
# This is an auto-generated Django model module. # You'll have to do the following manually to clean this up: # * Rearrange models' order # * Make sure each model has one field with primary_key=True # * Make sure each ForeignKey and OneToOneField has `on_delete` set to the desired behavior # * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table # Feel free to rename the models, but don't rename db_table values or field names. from django.db import models from django.urls import reverse from django.contrib.auth.models import User from django.utils import timezone # from django_mongoengine import Document, EmbeddedDocument # from django_mongoengine import fields # class User overridden? -> settings.AUTH_USER_MODEL class Admin(models.Model): admin_user_id = models.CharField(db_column='adminUserID', primary_key=True, max_length=45) # Field name made lowercase. password = models.CharField(db_column='passWord', max_length=15) # Field name made lowercase. class Meta: db_table = 'Admins' def __str__(self): return self.admin_user_id class Member(models.Model): user_id = models.CharField(db_column='userID', primary_key=True, max_length=45) # Field name made lowercase. password = models.CharField(db_column='passWord', max_length=15) # Field name made lowercase. class Meta: db_table = 'Members' def __str__(self): return self.user_id class Book(models.Model): book_id = models.IntegerField(db_column='bookID', primary_key=True) # Field name made lowercase. borrower_id = models.ForeignKey(User, on_delete=models.SET_NULL, db_column='borrowerID', blank=True, null=True, related_name='loans') # Field name made lowercase. reserver_id = models.ForeignKey(User, on_delete=models.SET_NULL, db_column='reserverID', blank=True, null=True, related_name='reservations') # Field name made lowercase. start_date = models.DateField(db_column='startDate', blank=True, null=True) # Field name made lowercase. due_date = models.DateField(db_column='dueDate', blank=True, null=True) # Field name made lowercase. reserve_due_date = models.DateField(db_column='reserveDueDate', blank=True, null=True) # Field name made lowercase. return_date = models.DateField(db_column='returnDate', blank=True, null=True) # Field name made lowercase. class Meta: ordering = ['book_id'] db_table = 'Books' def __str__(self): return str(self.book_id) def get_absolute_url(self): """Returns the url to access a particular book instance.""" return reverse('book_details', args=[str(self.book_id)]) @property def is_overdue(self): return timezone.now().date() > self.due_date class Fine(models.Model): user_id = models.OneToOneField(User, on_delete=models.CASCADE, db_column='userID', primary_key=True, related_name='fines') # Field name made lowercase. amount = models.FloatField(blank=True, null=True) class Meta: db_table = 'Fines' def __str__(self): return f'{self.user_id} owes ${self.amount} fine' class Payment(models.Model): transaction_time = models.DateTimeField(db_column='transactionTime') # Field name made lowercase. user_id = models.ForeignKey(User, on_delete=models.CASCADE, db_column='userID', related_name='payments') # Field name made lowercase. amount = models.FloatField(db_column='paid', blank=True, null=True) card = models.CharField(max_length=20, blank=True, null=True) class Meta: ordering = ['-transaction_time'] db_table = 'Payments' def __str__(self): return f'{self.user_id} paid {self.amount} at {self.transaction_time}'
[ "77076051+uyencfi@users.noreply.github.com" ]
77076051+uyencfi@users.noreply.github.com
e3e79b260ab8dff587ac9348051e9ff68a59b318
6a80a15b45cd578bd6a496566474fa6583f6fc13
/docs/build/html/_downloads/1e860c42938854d6b061aff9d370f07a/dietmodel.py
d209b0d926ef94b0736a955bc7314f1060841f20
[ "BSD-3-Clause" ]
permissive
ytakashina/amplpy
3c67efcb78ea6c5fac828e025e4be91e3dd7eba0
6338e7eab44167c776c16a1da23352bed5910288
refs/heads/master
2021-05-25T07:33:43.982436
2020-02-28T02:14:06
2020-02-28T02:14:06
253,718,165
0
0
BSD-3-Clause
2020-04-07T07:24:21
2020-04-07T07:24:21
null
UTF-8
Python
false
false
2,202
py
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function, absolute_import, division from builtins import map, range, object, zip, sorted import sys import os def main(argc, argv): from amplpy import AMPL, DataFrame os.chdir(os.path.dirname(__file__) or os.curdir) try: ampl = AMPL() if argc > 1: ampl.setOption('solver', argv[1]) # Read the model file modelDirectory = argv[2] if argc == 3 else os.path.join('..', 'models') ampl.read(os.path.join(modelDirectory, 'diet/diet.mod')) foods = ['BEEF', 'CHK', 'FISH', 'HAM', 'MCH', 'MTL', 'SPG', 'TUR'] costs = [3.59, 2.59, 2.29, 2.89, 1.89, 1.99, 1.99, 2.49] fmin = [2, 2, 2, 2, 2, 2, 2, 2] fmax = [10, 10, 10, 10, 10, 10, 10, 10] df = DataFrame('FOOD') df.setColumn('FOOD', foods) df.addColumn('cost', costs) df.addColumn('f_min', fmin) df.addColumn('f_max', fmax) ampl.setData(df, 'FOOD') nutrients = ['A', 'C', 'B1', 'B2', 'NA', 'CAL'] nmin = [700, 700, 700, 700, 0, 16000] nmax = [20000, 20000, 20000, 20000, 50000, 24000] df = DataFrame('NUTR') df.setColumn('NUTR', nutrients) df.addColumn('n_min', nmin) df.addColumn('n_max', nmax) ampl.setData(df, 'NUTR') amounts = [ [ 60, 8, 8, 40, 15, 70, 25, 60], [ 20, 0, 10, 40, 35, 30, 50, 20], [ 10, 20, 15, 35, 15, 15, 25, 15], [ 15, 20, 10, 10, 15, 15, 15, 10], [928, 2180, 945, 278, 1182, 896, 1329, 1397], [295, 770, 440, 430, 315, 400, 379, 450] ] df = DataFrame(('NUTR', 'FOOD'), 'amt') df.setValues({ (nutrient, food): amounts[i][j] for i, nutrient in enumerate(nutrients) for j, food in enumerate(foods) }) ampl.setData(df) ampl.solve() print('Objective: {}'.format(ampl.getObjective('total_cost').value())) except Exception as e: print(e) raise if __name__ == '__main__': main(len(sys.argv), sys.argv)
[ "fdabrandao@gmail.com" ]
fdabrandao@gmail.com
b5d4935ccb2e390451e2a6cdf3d02b0c3c62fed1
771d3c54b5f18c87f9f8f5f03992a639c40b2391
/Prediction/multiple_linear_regression.py
b030b6a982f10926d5d7cced28cf718ca1aaf946
[]
no_license
simayhosmeyve/Machine_Learning
87039ee3f118014cb9a58e302350721a458aed9c
15d4199d888b703141b1249afc026d9ee6fbb27b
refs/heads/main
2023-06-29T01:18:07.225083
2021-07-30T12:43:14
2021-07-30T12:43:14
384,386,396
1
0
null
null
null
null
UTF-8
Python
false
false
2,592
py
#tahminimiz birden fazla parametreye bağlı olduğunda import numpy as np import matplotlib.pyplot as plt import pandas as pd datas = pd.read_csv('values.csv') #print(datas) age = datas.iloc[:,1:4].values #print(age) #encoding country = datas.iloc[:,0:1].values print(country) from sklearn import preprocessing le = preprocessing.LabelEncoder() country[:,0] = le.fit_transform(datas.iloc[:,0]) print(country) ohe = preprocessing.OneHotEncoder(categories='auto') country = ohe.fit_transform(country).toarray() print(country) c = datas.iloc[:,-1:].values print(c) from sklearn import preprocessing le = preprocessing.LabelEncoder() c[:,-1] = le.fit_transform(datas.iloc[:,-1]) print(c) #numpy dizileri dataframe donusumu df = pd.DataFrame(data=country, index = range(22), columns = ['fr','tr','us']) print(df) df2 = pd.DataFrame(data=age, index = range(22), columns = ['boy','kilo','yas']) print(df2) cinsiyet = datas.iloc[:,-1].values print(cinsiyet) df3 = pd.DataFrame(data = c[:,:1], index = range(22), columns = ['cinsiyet']) print(df3) #dataframe birlestirme islemi s=pd.concat([df,df2], axis=1) print(s) s2=pd.concat([s,df3], axis=1) print(s2) #egitim ve test from sklearn.model_selection import train_test_split x_train, x_test,y_train,y_test = train_test_split(s,df3,test_size=0.33, random_state=0) from sklearn.linear_model import LinearRegression regressor = LinearRegression() regressor.fit(x_train,y_train) y_pred = regressor.predict(x_test) #boy değerleri tablodan alınıyor boy = s2.iloc[:,3:4].values print(boy) #eğitmek için boy kolununun solundaki ve sağındaki değerleri alıyoruz sol = s2.iloc[:,:3] sag = s2.iloc[:,4:] veri = pd.concat([sol,sag],axis=1) x_train, x_test,y_train,y_test = train_test_split(veri,boy,test_size=0.33, random_state=0) r2 = LinearRegression() r2.fit(x_train,y_train) y_pred = r2.predict(x_test) #Backward Elimination import statsmodels.api as sm #Verileri eleyerek daha iyi bir tahmine ulaşmaya çalışıyoruz #En yüksek p value alan değişken elenir #array oluşturuyoruz X = np.append(arr = np.ones((22,1)).astype(int), values = veri , axis = 1) X_l = veri.iloc[:,[0,1,2,3,4,5]].values X_l = np.array(X_l,dtype=float) #OLS raporu çıkartılıyor r_ols = sm.OLS(endog=boy,exog=X_l) r = r_ols.fit() print(r.summary()) #p value yüksek olduğu için 4'ü çıkarıyoruz X_l = veri.iloc[:,[0,1,2,3,5]].values X_l = np.array(X_l,dtype=float) r_ols = sm.OLS(endog=boy,exog=X_l) r = r_ols.fit() print(r.summary())
[ "noreply@github.com" ]
simayhosmeyve.noreply@github.com
2d14551e314dc6fae1cd93c261da3bce2b6a090a
765e850116564d47d7ac3afa38ac2c56ccd1ce29
/ScMiles/log.py
5989bef6307a5f3e618b10a73ef1894f03500ed5
[]
no_license
UTmilestoning/ScMiles2.0
87c7ff9f874aa81392e551c885872be1d1818c48
edd23d864834a0e773207b80367a1b68f31cc2c0
refs/heads/master
2023-06-14T11:41:52.204370
2020-09-21T15:45:27
2020-09-21T15:45:27
315,404,147
2
1
null
null
null
null
UTF-8
Python
false
false
573
py
# -*- coding: utf-8 -*- """ Created on Sun Sep 16 15:49:08 2018 @author: Wei Wei This subroutine writes running informations to log file. """ __all__ = ['log'] def log(msg): import os from datetime import datetime filePath = os.path.dirname(os.path.abspath(__file__)) outfolder = os.path.abspath(os.path.join(filePath, os.pardir)) + '/my_project_output/current' with open(outfolder+'/log', 'a+') as f1: loginfo = str(datetime.now()).split('.')[0] + " " + msg print(loginfo, file=f1) if __name__ == '__main__': log('test')
[ "noreply@github.com" ]
UTmilestoning.noreply@github.com
430652a45790d6c43467152d40c8acc63a0b0613
cb901633a8cf535098893bcf9cd6daf16e0c7de8
/mlfinlab/tests/test_functional_correlation_driven_nonparametric_learning_k.py
92b4115e9d7cd3a54794a849754720bacdba3166
[]
no_license
webclinic017/pandas-polygon
997de5d4f4c9423f158bda82a1cfae8e5b110e93
1caa0266f830181e632568332ee4c3ccb1878114
refs/heads/master
2023-08-25T01:34:51.770044
2021-02-07T05:55:58
2021-02-07T05:55:58
298,890,629
1
0
null
null
null
null
UTF-8
Python
false
false
4,105
py
# Copyright 2019, Hudson and Thames Quantitative Research # All rights reserved # Read more: https://github.com/hudson-and-thames/mlfinlab/blob/master/LICENSE.txt """ Tests Functional Correlation Driven Nonparametric Learning - K. """ from unittest import TestCase import os import numpy as np import pandas as pd from mlfinlab.online_portfolio_selection.fcornk \ import FCORNK class TestFunctionalCorrelationDrivenNonparametricLearningK(TestCase): # pylint: disable=unsubscriptable-object """ Tests different functions of the Functional Correlation Driven Nonparametric Learning - K class. """ def setUp(self): """ Sets the file path for the tick data csv. """ # Set project path to current directory. project_path = os.path.dirname(__file__) # Add new data path to match stock_prices.csv data. data_path = project_path + '/test_data/stock_prices.csv' # Read csv, parse dates, and drop NaN. self.data = pd.read_csv(data_path, parse_dates=True, index_col="Date").dropna(axis=1) def test_fcorn_k_solution(self): """ Test the calculation of FCORN-K. """ # Initialize FCORN-K. fcorn_k = FCORNK(window=1, rho=1, lambd=1, k=1) # Allocates asset prices to FCORN-K. fcorn_k.allocate(self.data, resample_by='3M') # Create np.array of all_weights. all_weights = np.array(fcorn_k.all_weights) # Check if all weights sum to 1. for i in range(all_weights.shape[0]): weights = all_weights[i] assert (weights >= 0).all() assert len(weights) == self.data.shape[1] np.testing.assert_almost_equal(np.sum(weights), 1) def test_fcorn_k_window_error(self): """ Tests ValueError if window is not an integer or less than 1. """ # Initialize FCORN-K. fcorn_k1 = FCORNK(window=2.5, rho=2, lambd=1, k=1) with self.assertRaises(ValueError): # Running allocate will raise ValueError. fcorn_k1.allocate(self.data) # Initialize FCORN-K. fcorn_k2 = FCORNK(window=0, rho=2, lambd=1, k=1) with self.assertRaises(ValueError): # Running allocate will raise ValueError. fcorn_k2.allocate(self.data) def test_fcorn_k_rho_error(self): """ Tests ValueError if rho is not an integer or less than 1. """ # Initialize FCORN-K. fcorn_k3 = FCORNK(window=2, rho=2.5, lambd=1, k=1) with self.assertRaises(ValueError): # Running allocate will raise ValueError. fcorn_k3.allocate(self.data) # Initialize FCORN-K. fcorn_k4 = FCORNK(window=2, rho=0, lambd=1, k=1) with self.assertRaises(ValueError): # Running allocate will raise ValueError. fcorn_k4.allocate(self.data) def test_fcorn_k_lambd_error(self): """ Tests ValueError if lambd is not an integer or less than 1. """ # Initialize FCORN-K. fcorn_k5 = FCORNK(window=2, rho=2, lambd=1.5, k=1) with self.assertRaises(ValueError): # Running allocate will raise ValueError. fcorn_k5.allocate(self.data) # Initialize FCORN-K. fcorn_k6 = FCORNK(window=2, rho=2, lambd=0, k=1) with self.assertRaises(ValueError): # Running allocate will raise ValueError. fcorn_k6.allocate(self.data) def test_fcorn_k_k_error(self): """ Tests ValueError if k is not an integer of greater than window * rho * lambd """ # Initialize FCORN-K. fcorn_k7 = FCORNK(window=2, rho=2, lambd=2, k=16) with self.assertRaises(ValueError): # Running allocate will raise ValueError. fcorn_k7.allocate(self.data) # Initialize FCORN-K. fcorn_k8 = FCORNK(window=2, rho=2, lambd=2, k=1.2) with self.assertRaises(ValueError): # Running allocate will raise ValueError. fcorn_k8.allocate(self.data)
[ "bob@instasize.com" ]
bob@instasize.com
e6cdb794aa311080ffa4e7aa83cbc4f90ff8ac96
bf99b1b14e9ca1ad40645a7423f23ef32f4a62e6
/AtCoder/abc/141b.py
4460bbf6a3ef087667c285aeff68758cdaf4a860
[]
no_license
y-oksaku/Competitive-Programming
3f9c1953956d1d1dfbf46d5a87b56550ff3ab3db
a3ff52f538329bed034d3008e051f30442aaadae
refs/heads/master
2021-06-11T16:14:12.635947
2021-05-04T08:18:35
2021-05-04T08:18:35
188,639,647
0
0
null
null
null
null
UTF-8
Python
false
false
550
py
import sys from heapq import heappop, heappush from operator import itemgetter from collections import deque, defaultdict, Counter from bisect import bisect_left, bisect_right input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) MOD = 10**9 + 7 INF = float('inf') def sol(): S = input().rstrip() for i, s in enumerate(S): if i % 2 == 0: if s == 'L': print('No') return else: if s == 'R': print('No') return print('Yes') sol()
[ "y.oksaku@stu.kanazawa-u.ac.jp" ]
y.oksaku@stu.kanazawa-u.ac.jp
4bc43753732ed7e0fa52c7b70d1c3c86e150fcc8
a7bef1217d295a0461697073d88825ea37ce6151
/dtft.py
f6783787b018bf255c57ff9e68274b817c2bbd20
[]
no_license
R151837/PRIYANKA
a5cdd2e798c6c02fa6706a37f97dd7dd57846956
4d3c2d5165a97594b237b3999ce2536322326c22
refs/heads/master
2020-04-27T06:50:25.547913
2019-03-06T10:11:51
2019-03-06T10:11:51
174,119,366
0
0
null
null
null
null
UTF-8
Python
false
false
402
py
import numpy as np import matplotlib.pyplot as plt import cmath as cm x=input('enter sequence=') n=len(x) j=cm.sqrt(-1) w=np.linspace(0,2*np.pi,1000) y=[] for i in range(0,1000): sum=0 for k in range(0,n): sum=sum+x[k]*np.exp(-j*w[i]*k) y=np.append(y,sum) print y plt.subplot(121) plt.title("magnitude") plt.plot(w,np.abs(y)) plt.subplot(122) plt.title("phase") plt.plot(w,np.angle(y)) plt.show()
[ "noreply@github.com" ]
R151837.noreply@github.com
f004c169097cf2b61b4fc0c52f64922958d33f99
fcbc1f173579556bd75473d5be190c1229c0dfaa
/first10.py
46957cddeb38259e69eefdb283ea03a32d6f15ca
[]
no_license
Hiten1502/codeQuotient-Automation
09424fb5c3eba17c89fea4787e8c167c415406c7
58199762ee776a86418af2cc5f4ff753dee19b93
refs/heads/main
2023-07-13T10:46:03.531186
2021-08-22T06:19:31
2021-08-22T06:19:31
398,727,244
1
0
null
null
null
null
UTF-8
Python
false
false
81,962
py
from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.chrome.options import Options from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.action_chains import ActionChains import time import getpass import pyautogui import pyperclip dollar = "$" * 99 # User Inputs print('\n', dollar) print('') print('Coding is Just Like Copy And Paste') print("Please check all the configurations before proceeding !!!") print('\n') print("Made For You By Hiten Singla And Sahil Vats") print("Github Profile ----> https://github.com/Hiten1502") print('\n', dollar) username = input('Enter Your Email: ') password = getpass.getpass(prompt='Enter Your Password:') # Importing Chrome Driver driver_path = "./chromedriver.exe" chrome_options = Options() driver = webdriver.Chrome(executable_path=driver_path, options=chrome_options) # Where the Magic happens function time.sleep(2) driver.get("https://codequotient.com/login") time.sleep(2) driver.find_element_by_id("email").send_keys(username) time.sleep(2) driver.find_element_by_id("password").send_keys(password) time.sleep(2) driver.find_element_by_id("btnSubmit").click() time.sleep(2) ############################################################ driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5b372a8af8379219939149f9") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.execute_script("arguments[0].click();",button[1]) time.sleep(2) driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5b372db4f837921993914a10") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.execute_script("arguments[0].click();",button[1]) time.sleep(2) driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5b3cdc4cf837921993916934") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.execute_script("arguments[0].click();",button[1]) time.sleep(2) driver.execute_script("arguments[0].click();",button[2]) time.sleep(2) driver.execute_script("arguments[0].click();",button[3]) time.sleep(2) driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5b4c9d2d2a3f026b0f4f0e21") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.execute_script("arguments[0].click();",button[1]) time.sleep(2) driver.execute_script("arguments[0].click();",button[2]) time.sleep(2) driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5b3cde35f83792199391693e") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.execute_script("arguments[0].click();",button[1]) time.sleep(2) driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5b4747a734eb16221f491227") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.execute_script("arguments[0].click();",button[1]) time.sleep(2) driver.execute_script("arguments[0].click();",button[2]) time.sleep(2) driver.execute_script("arguments[0].click();",button[3]) time.sleep(2) driver.execute_script("arguments[0].click();",button[4]) time.sleep(2) # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5aa2a1665ead875d7faa97f7")#link driver.find_element_by_id("txtOutput0").send_keys("11") driver.find_element_by_id("txtOutput1").send_keys("6") driver.find_element_by_id("txtOutput2").send_keys("30") driver.find_element_by_id("txtOutput3").send_keys("1") driver.find_element_by_id("txtOutput4").send_keys("7") driver.find_element_by_id("txtOutput5").send_keys("5") driver.find_element_by_id("txtOutput6").send_keys("2") driver.find_element_by_id("txtOutput7").send_keys("18") driver.find_element_by_id("txtOutput8").send_keys("3") driver.find_element_by_id("txtOutput9").send_keys("4") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5aa2a2a15ead875d7faa9808")#link driver.find_element_by_id("txtOutput0").send_keys("9.0") driver.find_element_by_id("txtOutput1").send_keys("9.6") driver.find_element_by_id("txtOutput2").send_keys("2.2") driver.find_element_by_id("txtOutput3").send_keys("6.0") driver.find_element_by_id("txtOutput4").send_keys("6.0") driver.find_element_by_id("txtOutput5").send_keys("8.0") driver.find_element_by_id("txtOutput6").send_keys("1.25") driver.find_element_by_id("txtOutput7").send_keys("3.0") driver.find_element_by_id("txtOutput8").send_keys("4.0") driver.find_element_by_id("txtOutput9").send_keys("6.4") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5aa2a3645ead875d7faa9814")#link driver.find_element_by_id("txtOutput0").send_keys("val1%10;") driver.find_element_by_id("txtOutput1").send_keys("val1/10%10;") driver.find_element_by_id("txtOutput2").send_keys("val1/100%10;") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5aa2a4275ead875d7faa9857")#link driver.find_element_by_id("txtOutput0").send_keys("(15*count-11)") driver.find_element_by_id("txtOutput1").send_keys("(-10*count+40)") driver.find_element_by_id("txtOutput2").send_keys("(4*count-11)") driver.find_element_by_id("txtOutput3").send_keys("(-3*count+100)") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5aa557b75ead875d7faab603")#link driver.find_element_by_id("txtOutput0").send_keys("true") driver.find_element_by_id("txtOutput1").send_keys("false") driver.find_element_by_id("txtOutput2").send_keys("false") driver.find_element_by_id("txtOutput3").send_keys("true") driver.find_element_by_id("txtOutput4").send_keys("true") driver.find_element_by_id("txtOutput5").send_keys("false") driver.find_element_by_id("txtOutput6").send_keys("true") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5b41bb0af83792199391808e")#link driver.find_element_by_id("txtOutput0").send_keys("7") driver.find_element_by_id("txtOutput1").send_keys("8") driver.find_element_by_id("txtOutput2").send_keys("7") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) # c1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a2e09056dc3de029e4889e6")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" # include<bits/stdc++.h> using namespace std; int main(){ int n;cin>>n; if(n%2 == 0){ cout<<"Even"<<endl; } else{ cout<<"Odd"<<endl; } return 0; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a2e123c6dc3de029e488a24")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" # include<bits/stdc++.h> using namespace std; int main(){ int arr[3]; for (int i = 0; i < 3; i++) { cin>>arr[i]; } cout<<(*max_element(arr,arr+3))<<endl; return 0; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a2e0c006dc3de029e4889fb")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" # include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; if(n%4==0){ if(n%100==0 && n%400!=0){ cout<<"Not a Leap Year"; } else{ cout<<"Leap Year"; } } else{ cout<<"Not a Leap Year"; } return 0; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5d46dfdf695fda3b2cd0ac34")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" # include<bits/stdc++.h> using namespace std; int main(){ int arr[] = {2000, 500, 100, 50, 20, 10, 5, 2, 1}; int n;cin>>n; int x = sizeof(arr)/sizeof(arr[0]); for (int i = 0; i < x; i++) { int z = n/arr[i]; n = n - z*arr[i]; arr[i] = z; } for (int i = 0; i < x; i++) { cout<<arr[i]<<" "; } return 0; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a2e1fd86dc3de029e488a94")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" #include<iostream> //#include<cstdio> //#include<cmath> using namespace std; int main() { int n; cin>>n; int sum=0; for(int i=1;i<=n;i++){ sum=sum+i; } cout<<sum; return 0; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a2e30b56dc3de029e488ad4")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" #include <iostream> using namespace std; int main(){ int n; cin>>n; for (int i = 1; i <= n; i++){ for(int j=i;j>=1;j--){ cout<<j; } for(int j=2;j<=i;j++){ cout<<j; } cout<<endl; } return 0; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a2e33116dc3de029e488ad7")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" # include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; int p =1; for (int i = 1; i <= n; i++) { for (int j = 1; j <= i; j++) { cout<<p; if(j != i){ cout<<" "; } p++; } cout<<endl; } return 0; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a2e35746dc3de029e488ade")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" # include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; for (int i = 0; i < 1; i++) { for (int j = 1; j < n-i+1; j++) { cout<<j; } int p = n-i-1; for (int j = 1; j < n; j++) { cout<<p; p--; } cout<<endl; } for (int i = 0; i < n-1; i++) { for (int j = 0; j < n-i-1; j++) { cout<<j+1; } for (int j = 0; j < 2*i+1; j++) { cout<<"*"; } int p = n - i-1; for (int j = 0; j < (n-i-1); j++) { cout<<p; p--; } cout<<endl; } return 0; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a2e20796dc3de029e488a9b")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" # include<bits/stdc++.h> using namespace std; int main(){ int n,m; cin>>n>>m; for (int i = 1; i <= m; i++) { cout<<(n*i)<<endl; } return 0; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) ##########################################################3 #############################################33 driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5b419ab5f837921993917f93") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.execute_script("arguments[0].click();",button[1]) time.sleep(2) driver.execute_script("arguments[0].click();",button[2]) time.sleep(2); driver.execute_script("arguments[0].click();",button[3]) time.sleep(2) driver.execute_script("arguments[0].click();",button[4]) time.sleep(2); driver.execute_script("arguments[0].click();",button[5]) time.sleep(2) driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5b38c52fc6a1d0259e728e74") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5b4a01613714c2304e8557ea") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.execute_script("arguments[0].click();",button[1]) time.sleep(2) # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5b41b68df83792199391806c")#link driver.find_element_by_id("txtOutput0").send_keys("-2 + 4 = 7") driver.find_element_by_id("txtOutput1").send_keys("4 + -2 = 3") driver.find_element_by_id("txtOutput2").send_keys("2 + 11 = 5") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5b41b6e7f837921993918071")#link driver.find_element_by_id("txtOutput0").send_keys("12") driver.find_element_by_id("txtOutput1").send_keys("2") driver.find_element_by_id("txtOutput2").send_keys("16") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5b41b7f9f837921993918077")#link driver.find_element_by_id("txtOutput0").send_keys("1342213422") driver.find_element_by_id("txtOutput1").send_keys("""quotient and coding like code code and quotient like coding """) WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5b41b8c5f83792199391807e")#link driver.find_element_by_id("txtOutput0").send_keys(""" cq3: x = 23, y = 7 cq2: x = 12, y = 1, z = 7 cq1: x = 7, y = 11, z = 12 """) driver.find_element_by_id("txtOutput1").send_keys(""" cq3: x = 44, y = 11 cq2: x = 23, y = 1, z = 11 cq1: x = 11, y = 21, z = 23 """) WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) # c1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a4e652dd2b99733e5c16900")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" int sumOfRange(int min, int max){ int sum(0); for (int i = min; i <= max; i++) { sum += i; } return sum; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a093c7917bcb854c302bd23")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" /* * Complete the function 'verifyPrime' * @params * n ->number which is to be checked from primality test * * @return * true if the number is a prime number else false */ bool verifyPrime(int n){ // Write your code her if(n == 0 || n == 1){ return false; } for (int i = 2; i < n; i++) { if(n%i == 0){ return false; } } return true; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a11753954305147defdced0")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" /* * Complete the function 'primeFactors' * Print all the prime factors of the number * @params * n -> numbers whose prime factors are to be found */ void primeFactors(int n){ // Write your code here while (n%2 == 0) { printf("%d", 2); cout<<endl; n = n/2; } for (int i = 3; i <= sqrt(n); i = i+2) { while (n%i == 0) { printf("%d", i); cout<<endl; n = n/i; } } if (n > 2) printf ("%d", n); cout<<endl; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a1056fb54305147defdcec2")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" /* * Complete the function 'gcd' * @params * i -> first integer * j -> second integer * * @returns * an integer, denoting the gcd of i and j */ int gcd(int i, int j){ if(j == 0){ return i; } return gcd(j,i%j); } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a4e7676d2b99733e5c16921")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" int binaryToDecimal(string binary){ string num=binary; int sum=0; int base=1; for (int i=num.length()-1;i>=0;i--){ if (num[i]=='1'){ sum+=base; } base=base*2; } return sum; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5b41bb0af83792199391808e")#link driver.find_element_by_id("txtOutput0").send_keys("7") driver.find_element_by_id("txtOutput1").send_keys("8") driver.find_element_by_id("txtOutput2").send_keys("7") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5b41ba29f837921993918087")#link driver.find_element_by_id("txtOutput0").send_keys("m1-ii") driver.find_element_by_id("txtOutput1").send_keys("Error") driver.find_element_by_id("txtOutput2").send_keys("m1-if") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) # c1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5b4a03903714c2304e8557f4")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" // write the overloaded sum() functions for 2, 3 and 4 arguments int sum(int a,int b){ return a+b; } int sum(int a,int b,int c){ return a+b+c; } int sum(int a,int b,int c,int d){ return a+b+c+d; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5b4a06483714c2304e8557fc")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" // Write overloaded display(string a) and display(string a, string b) functions void display(string a){ cout<<a; } void display(string a,string b){ cout<<a<<"-"; cout<<b; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) #######################################################33333333333 driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5a006a24e63d6b7fd5dec29b") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.execute_script("arguments[0].click();",button[1]) time.sleep(2) driver.execute_script("arguments[0].click();",button[2]) time.sleep(2) driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5a006b92e63d6b7fd5dec2bb") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5a006a7de63d6b7fd5dec2a6") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.execute_script("arguments[0].click();",button[1]) time.sleep(2) driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5a006ac5e63d6b7fd5dec2ae") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5b419e91f837921993917fb1") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.execute_script("arguments[0].click();",button[1]) time.sleep(2); driver.execute_script("arguments[0].click();",button[2]) time.sleep(2); driver.execute_script("arguments[0].click();",button[3]) time.sleep(2); driver.execute_script("arguments[0].click();",button[4]) time.sleep(2); driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5b3908e9c6a1d0259e728f8f") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.execute_script("arguments[0].click();",button[1]) time.sleep(2); # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a411e7f1fa97021c32ce070")#link driver.find_element_by_id("txtOutput0").send_keys("70 25") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a411ec71fa97021c32ce073")#link driver.find_element_by_id("chkOpt4").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a411f161fa97021c32ce074")#link driver.find_element_by_id("txtOutput0").send_keys("31") driver.find_element_by_id("txtOutput1").send_keys("1004") driver.find_element_by_id("txtOutput2").send_keys("1004") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a411f731fa97021c32ce079")#link driver.find_element_by_id("chkOpt1").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a2bcdae6dc3de029e4887c8")#link driver.find_element_by_id("chkOpt4").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5b4ad952f5c97d305544b0d7")#link driver.find_element_by_id("txtOutput0").send_keys("68") driver.find_element_by_id("txtOutput1").send_keys("88") driver.find_element_by_id("txtOutput2").send_keys("76") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5b44c4dce25fb6141524a0ef")#link driver.find_element_by_id("txtOutput1").send_keys("True") driver.find_element_by_id("txtOutput0").send_keys("True") driver.find_element_by_id("txtOutput2").send_keys("True") driver.find_element_by_id("txtOutput3").send_keys("False") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5b44c555e25fb6141524a0f5")#link driver.find_element_by_id("txtOutput0").send_keys("No") driver.find_element_by_id("txtOutput1").send_keys("Yes") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5b44c69de25fb6141524a0f9")#link driver.find_element_by_id("txtOutput0").send_keys("True") driver.find_element_by_id("txtOutput1").send_keys("True") driver.find_element_by_id("txtOutput2").send_keys("False") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5b4ada9ef5c97d305544b0dc")#link driver.find_element_by_id("chkOpt2").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5b4adc14f5c97d305544b0dd")#link driver.find_element_by_id("txtOutput0").send_keys("0") driver.find_element_by_id("txtOutput1").send_keys("2") driver.find_element_by_id("txtOutput2").send_keys("2") driver.find_element_by_id("txtOutput3").send_keys("1") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5b4adcddf5c97d305544b0e3")#link driver.find_element_by_id("chkOpt2").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) # c1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5ca2e6c893d7f626b4060811")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" vector<int> cutSticks(vector<int> lengths) { sort(lengths.begin() , lengths.end()); int shortest = INT_MIN; vector<int> ans; for(int i=0;i<lengths.size();i++){ if(lengths[i] > shortest){ ans.push_back(lengths.size() -i); shortest = lengths[i]; } } return ans; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) #########################################################3 driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5b38c12dc6a1d0259e728e56") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.execute_script("arguments[0].click();",button[1]) time.sleep(2) driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5b38c21fc6a1d0259e728e63") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.execute_script("arguments[0].click();",button[1]) time.sleep(2) driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5b38c902c6a1d0259e728e9b") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.execute_script("arguments[0].click();",button[1]) time.sleep(2) driver.execute_script("arguments[0].click();",button[2]) time.sleep(2) driver.execute_script("arguments[0].click();",button[3]) time.sleep(2) driver.execute_script("arguments[0].click();",button[4]) time.sleep(2) driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5b38c9aac6a1d0259e728ea9") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5b18b68d7becc0459de9bf72")#link driver.find_element_by_id("chkOpt2").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5b41e78a378b141faaf16c23")#link driver.find_element_by_id("chkOpt4").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5b41e856378b141faaf16c5c")#link driver.find_element_by_id("txtOutput0").send_keys("No") driver.find_element_by_id("txtOutput1").send_keys("No") driver.find_element_by_id("txtOutput2").send_keys("Yes") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5b41e8fa378b141faaf16c6c")#link driver.find_element_by_id("txtOutput0").send_keys("No") driver.find_element_by_id("txtOutput1").send_keys("Yes") driver.find_element_by_id("txtOutput2").send_keys("No") driver.find_element_by_id("txtOutput3").send_keys("No") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5b41ea32378b141faaf16c7b")#link driver.find_element_by_id("txtOutput0").send_keys("No") driver.find_element_by_id("txtOutput1").send_keys("No") driver.find_element_by_id("txtOutput2").send_keys("Yes") driver.find_element_by_id("txtOutput3").send_keys("No") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5b41ea7f378b141faaf16c81")#link driver.find_element_by_id("txtOutput0").send_keys("No") driver.find_element_by_id("txtOutput1").send_keys("No") driver.find_element_by_id("txtOutput2").send_keys("Yes") driver.find_element_by_id("txtOutput3").send_keys("No") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5b4ae0d2f5c97d305544b0ec")#link driver.find_element_by_id("txtOutput0").send_keys("Modular") driver.find_element_by_id("txtOutput1").send_keys("Monolithic") driver.find_element_by_id("txtOutput2").send_keys("Object-Oriented") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) # c1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5aba57adecf32f0f52165aa5")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" class TimeSpan { private: int hours; private: int minutes; public: TimeSpan(int initialHours, int initialMin){ hours = 0; minutes = 0; add(initialHours, initialMin); } public: int getHours(){ return hours; } public: int getMinutes(){ return minutes; } public: void add(int initialHours, int initialMin){ hours += initialHours; minutes += initialMin; if(minutes >= 60){ minutes -= 60; hours++; } } public: void add(TimeSpan tp){ add(tp.hours, tp.minutes); } public: double getTotalHours(){ return hours + minutes / 60.0; } public: std::string toString(){ std::string str{std::to_string(hours)+" Hours, "+std::to_string(minutes)+" Minutes"}; return str; } }; """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5aba5b3becf32f0f52165adb")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" class Date { // Write your code here private: int month,day; public: Date(int m,int d){ month=m; day=d; } int daysInMonth(){ if(month==4|| month==6 || month==9 || month==11){ return 30; }else if(month==2){ return 28; } else{ return 31; } } int getDay(){ return day; } int getMonth(){ return month; } void nextDay(){ day++; if(day>=daysInMonth()){ month++; day=1; if(month>12){ month=1; } } } string toString(){ string result=""; result+=to_string(month); result+="/"; result+=to_string(day); return result; } int absoluteDay(){ int days; days=day; switch(getMonth()){ case 2: days+=31; break; case 3: days+=31+28; break; case 4: days+=31+28+31; break; case 5: days+=31+28+31+30; break; case 6: days+=31+28+31+30+31; break; case 7: days+=31+28+31+30+31+30; break; case 8: days+=31+28+31+30+31+30+31; break; case 9: days+=31+28+31+30+31+30+31+31; break; case 10: days+=31+28+31+30+31+30+31+31+30; break; case 11: days+=31+28+31+30+31+30+31+31+31; break; case 12: days+=31+28+31+30+31+30+31+31+31+30+30; break; } return days; } }; """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5b4cad9d2a3f026b0f4f0fc9")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" int cnt=0; // manipluate this variable in your code class Counter { public: Counter(){ cnt++; //cout<<"c1 id "<<cnt<<endl; } ~Counter(){ cnt--; //cout<<"c2 id "<<cnt<<endl; } }; """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) #######################################333 driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/60db0fb0a85d46f848f4c912"); time.sleep(2) driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/60db1774a85d46f848f4c915"); time.sleep(2) driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5a4a420eb1afa55f38fed780"); time.sleep(2) button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.execute_script("arguments[0].click();",button[1]) time.sleep(2) driver.execute_script("arguments[0].click();",button[2]) time.sleep(2) ###########################Array Module####################33 driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/59fde2a0e63d6b7fd5dec004") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.execute_script("arguments[0].click();",button[1]) time.sleep(2) driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/59fde6f5e63d6b7fd5dec01e") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); # driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5a12edf146765b2b63e3476b") # button = driver.find_elements_by_xpath("//a[text()='run']") # driver.execute_script("arguments[0].click();",button[0]) # time.sleep(2); # driver.execute_script("arguments[0].click();",button[1]) # time.sleep(2); # MCQ1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a42313b1fa97021c32ce0a3")#link time.sleep(2) driver.find_element_by_id("txtOutput0").send_keys("1 2 3 4 5") driver.find_element_by_id("txtOutput1").send_keys("5 4 3 2 1") driver.find_element_by_id("txtOutput2").send_keys("5 -15 -58 -35 25") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) # MCQ2 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a42313b1fa97021c32ce0a3")#link driver.find_element_by_id("txtOutput0").send_keys("1 2 3 4 5") driver.find_element_by_id("txtOutput1").send_keys("5 4 3 2 1") driver.find_element_by_id("txtOutput2").send_keys("5 -15 -58 -35 25") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) # MCQ2 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a4231711fa97021c32ce0a8")#link driver.find_element_by_id("txtOutput0").send_keys("1 -1 -4 -8 -13") driver.find_element_by_id("txtOutput1").send_keys("5 1 -2 -4 -5") driver.find_element_by_id("txtOutput2").send_keys("5 -60 -105 -107 -132") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a4231aa1fa97021c32ce0ad")#link driver.find_element_by_id("txtOutput0").send_keys("2 1 4 3 6") driver.find_element_by_id("txtOutput1").send_keys("6 3 4 1 2") driver.find_element_by_id("txtOutput2").send_keys("6 64 46 1 26 ") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a4231ef1fa97021c32ce0b2")#link driver.find_element_by_id("txtOutput0").send_keys("1 2 3 4 5") driver.find_element_by_id("txtOutput1").send_keys("5 4 3 2 1") driver.find_element_by_id("txtOutput2").send_keys("5 25 27 2 25") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a42359e1fa97021c32ce0c2")#link driver.find_element_by_id("chkOpt3").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a487f12b1afa55f38fed739")#link driver.find_element_by_id("chkOpt1").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a487f45b1afa55f38fed73a")#link driver.find_element_by_id("chkOpt1").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a487fabb1afa55f38fed73b")#link driver.find_element_by_id("chkOpt1").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) # c1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/59ff2beae63d6b7fd5dec1af")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" #include<iostream> #include<cstdio> #include<cmath> # include<bits/stdc++.h> // Include headers as needed using namespace std; int main() { int n = 5; int arr [n]; for(int i=0;i<n;i++){ cin>>arr[i]; } int max1 = INT_MIN , max2 = INT_MIN; for(int i=0;i<n;i++){ if(arr[i]>max1){ max1 = arr[i]; } } for(int j=0;j<n;j++){ if(arr[j]>max2 && arr[j]<max1){ max2 = max(max2 , arr[j]); } } if(max2 == INT_MIN){ cout<<0<<endl; } else{ cout<<max2; } return 0; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c2 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a4fb5ee7a3c1824dba91428")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" #include<iostream> #include<cstdio> #include<cmath> using namespace std; int main() { int T; cin>>T; for (int i = 0; i < T; i++) { int mf = 0; int max_count = 0; int n; cin>>n; int a[n]; for (int i = 0; i < n; i++) { cin>>a[i]; } for (int i = 0; i < n; i++) { int count = 0; for (int j = i+1; j < n; j++) { if(a[i] == a[j]){ count++; } if(count >= max_count){ max_count = count; mf = a[i]; } } } cout<<mf<<endl; } return 0; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a2e543e6dc3de029e488b37")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" # include<bits/stdc++.h> using namespace std; int main(){ int arr[10]; for (int i = 0; i < 10; i++) { cin>>arr[i]; } int neg(0),pos(0),even(0),odd(0); for (int i = 0; i < 10; i++) { if(arr[i]>=0){ pos++; } if(arr[i]<0){ neg++; } if(arr[i]%2 == 0){ even++; } else{ odd++; } } cout<<pos<<endl; cout<<neg<<endl; cout<<even<<endl; cout<<odd<<endl; return 0; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c4 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5d9f41ae5f73f530a20bd5d6")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" int arraysEqualorNot(vector<int> A, vector<int> B) { sort(A.begin(),A.end()); sort(B.begin(),B.end()); for (int i = 0; i < A.size(); i++) { if(A[i] != B[i]){ return 0; } } return 1; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a4fafbb7a3c1824dba9141c")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" void moveElements(int arr[], int n){ int key,j; for (int i = 0; i < n; i++) { key = arr[i]; j = i-1; while (j>=0 && arr[j]<0 && key>=0) { arr[j+1] = arr[j]; j--; } arr[j+1] = key; } } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) ###########################3333 #############################7th mod######################### driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5a12ef3746765b2b63e3477e") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.execute_script("arguments[0].click();",button[1]) time.sleep(2) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a487fdfb1afa55f38fed73c")#link driver.find_element_by_id("chkOpt1").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a48801bb1afa55f38fed73d")#link driver.find_element_by_id("txtOutput0").send_keys("9") driver.find_element_by_id("txtOutput1").send_keys("29") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a488049b1afa55f38fed741")#link driver.find_element_by_id("chkOpt2").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a488065b1afa55f38fed742")#link driver.find_element_by_id("chkOpt2").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) # c1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a4fc0117a3c1824dba91440")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" int getPairsCount(int arr[], int n, int sum){ // Write your code here int s=0; int l=n-1; int count=0; while(s<l){ if(arr[s]+arr[l]<sum) s++; else if(arr[s]+arr[l]==sum){ int p=l; while(arr[l]==arr[p] && p>s){ count++; p=p-1; } s++; } else{ l--; } } return count; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c2 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a50df747a3c1824dba915dc")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" # include<bits/stdc++.h> using namespace std; int find(int arr[],int n,int k){ for (int i = 0; i < n; i++) { if(arr[i] == k){ return i; break; } } return -1; } int main(){ int t;cin>>t; while (t--) { int n,k; cin>>n>>k; int arr[n]; for (int i = 0; i < n; i++) { cin>>arr[i]; } cout<<find(arr,n,k)<<endl; } return 0; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5d81f1f6e9156a66a25b7709")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" int rotationCount(int a[], int size){ int mn = *min_element(a,a+size); for (int i = 0; i < size; i++) { if(a[i] == mn){ return i; } } return 0; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c4 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a539b04f239e2076be893e8")#link t = driver.find_element_by_class_name("CodeMirror-code") t.click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" void sort(int arr[],int n){ for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { if (arr[i] > arr[j]) { int temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } } } } int getMissingElement(int* a,int a_size,int* b ,int b_size){ sort(a,a_size); sort(b,b_size); for (int i = 0; i < b_size; i++) { if(a[i] != b[i]){ return a[i]; } } return a[a_size-1]; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) #########################33 ###############################################333333 driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5a59dbc1a4af025f554a0bb2") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5a59dc57a4af025f554a0bbd") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5a59de12a4af025f554a0bcb") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.execute_script("arguments[0].click();",button[1]) time.sleep(2); driver.execute_script("arguments[0].click();",button[2]) time.sleep(2); driver.execute_script("arguments[0].click();",button[3]) time.sleep(2); driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5a59dcb5a4af025f554a0bc1") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5a59df31a4af025f554a0be8") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a6f280f89496f09677d64e9")#link driver.find_element_by_id("chkOpt3").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a6f287289496f09677d64f2")#link driver.find_element_by_id("chkOpt2").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a6f291189496f09677d64fd")#link driver.find_element_by_id("chkOpt1").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a6f298989496f09677d6527")#link driver.find_element_by_id("chkOpt4").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a6f29d789496f09677d652e")#link driver.find_element_by_id("txtOutput0").send_keys("True") driver.find_element_by_id("txtOutput1").send_keys("False") driver.find_element_by_id("txtOutput2").send_keys("True") driver.find_element_by_id("txtOutput3").send_keys("False") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a6f2ba289496f09677d6563")#link driver.find_element_by_id("chkOpt2").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a6f2be889496f09677d656d")#link driver.find_element_by_id("chkOpt2").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) # c1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a6f515c89496f09677d6947")#link t = driver.find_elements_by_class_name("CodeMirror-code") t[1].click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" /* struct Node { int data; struct Node* next; }; Above structure is used to define the linked list, You have to complete the below functions only */ void forwardPrint(struct Node* head) { if(head != NULL){ cout<<head->data<<"-"; forwardPrint(head->next); } } void backwardPrint(struct Node* head) { if(head != NULL){ backwardPrint(head->next); cout<<head->data<<"-"; } } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c2 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a70766389496f09677d7734")#link t = driver.find_elements_by_class_name("CodeMirror-code") t[1].click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" /* struct Node { int data; struct Node* next; }; Above structure is used to define the linked list, You have to complete the below functions only */ struct Node *copyList(struct Node *org) { Node *ptr = NULL; while (org != NULL) { insertEnd(&ptr , org->data); org = org->next; } return ptr; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a6f2ccb89496f09677d6585")#link driver.find_element_by_id("chkOpt3").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) # c1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a707dd489496f09677d78ad")#link t = driver.find_elements_by_class_name("CodeMirror-code") t[1].click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" /* struct Node { int data; struct Node* next; }; Above structure is used to define the linked list, You have to complete the below functions only */ # include<bits/stdc++.h> int minNode(Node *head){ Node *last = head; int min = INT_MAX; while (last != NULL) { if(last->data < min){ min = last->data; } last = last->next; } return min; } int maxNode(Node *head){ Node *last = head; int max = INT_MIN; while (last != NULL) { if(last->data > max){ max = last->data; } last = last->next; } return max; } void insertBeg(struct Node** head, int data){ struct Node* node = (struct Node*) malloc(sizeof(struct Node)); node->data = data; node->next = (*head); (*head) = node; } struct Node * shiftSmallLarge(struct Node *org) { int x = minNode(org); int y = maxNode(org); if(org == NULL){ return org; } Node *ptr = NULL; if(org->next == NULL){ insertBeg(&ptr , x); return ptr; } Node *last = org; while (last != NULL) { if(last->data == x){ last = last->next; } else if(last->data == y){ last = last->next; } else{ insertEnd(&ptr , last->data); last = last->next; } } insertBeg(&ptr , x); insertEnd(&ptr , y); return ptr; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c2 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a71b21d89496f09677d87e7")#link t = driver.find_elements_by_class_name("CodeMirror-code") t[1].click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" /* struct Node { int data; struct Node* next; }; Above structure is used to define the linked list, You have to complete the below functions only */ # include<bits/stdc++.h> int checkPalindrome(struct Node* head) { if(head == NULL){ return 0; } Node *ptr = head; stack<int> s; while (ptr != NULL) { s.push(ptr->data); ptr = ptr->next; } while (head != NULL) { int i = s.top(); s.pop(); if(head->data != i){ return 0; } head = head->next; } return 1; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a71aeac89496f09677d8758")#link t = driver.find_elements_by_class_name("CodeMirror-code") t[1].click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" /* struct Node { int data; Node* next; }; Above structure is used to define the linked list, You have to complete the below functions only */ int countNodes(struct Node *n) { int res = 1; struct Node *temp = n; while (temp->next != n) { res++; temp = temp->next; } return res; } int loopInList(Node* head) { struct Node *slow_p = head, *fast_p = head; while (slow_p && fast_p && fast_p->next) { slow_p = slow_p->next; fast_p = fast_p->next->next; if (slow_p == fast_p) return countNodes(slow_p); } return 0; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c4 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a71abef89496f09677d871c")#link t = driver.find_elements_by_class_name("CodeMirror-code") t[1].click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" /* struct Node { int data; struct Node* next; }; Above structure is used to define the linked list, You have to complete the below functions only */ Node *ptr = NULL; void giveReverse(Node *head){ ptr = NULL; if(head != NULL){ giveReverse(head->next); insertEnd(&ptr,head->data); } } struct Node* reverseList(struct Node* head) { giveReverse(head); return ptr; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a6f2ea689496f09677d65b4")#link driver.find_element_by_id("txtOutput0").send_keys("1 3 5 5 3 1") driver.find_element_by_id("txtOutput1").send_keys("1 2 3 3 2 1") driver.find_element_by_id("txtOutput2").send_keys("1 1 2 2 1 1") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a6f2fdd89496f09677d65e0")#link driver.find_element_by_id("chkOpt2").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a6f309a89496f09677d65f9")#link driver.find_element_by_id("txtOutput0").send_keys("2 1 4 3 6 5") driver.find_element_by_id("txtOutput1").send_keys("1 1 2 2 3 3") driver.find_element_by_id("txtOutput2").send_keys("1 1 2 1 2 2") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a6f317b89496f09677d6626")#link driver.find_element_by_id("chkOpt2").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) # c1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a71b40f89496f09677d880a")#link t = driver.find_elements_by_class_name("CodeMirror-code") t[1].click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" // struct Node // { // int data; // Node* next; // }; // Above node is used to declare a node Node* addListNumbers(Node* head1,Node* head2){ int x = 0; int i = 0; while (head1 != NULL) { int m = head1->data; x = m*pow(10,i) + x; i++; head1 = head1->next; } int y = 0; int j = 0; while (head2 != NULL) { int m = head2->data; y = m*pow(10,j) + y; j++; head2 = head2->next; } int sum = x+y; Node *ptr = NULL; while (sum > 0 ) { int x = sum%10; insertEnd(&ptr ,x); sum = sum/10; } return ptr; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c2 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a71b84689496f09677d8879")#link t = driver.find_elements_by_class_name("CodeMirror-code") t[1].click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" void deleteNodeK(Node* node){ if(node == NULL){ return; } if (node->next == NULL) { //free(node); return; } Node* temp = node->next; node->data = temp->data; node->next = temp->next; free(temp); } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) #########################################333 driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5a6342b4e2509a3288171d66") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5a634522e2509a3288171d76") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5a634448e2509a3288171d72") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5a6345c6e2509a3288171d7c") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a6f336f89496f09677d6669")#link driver.find_element_by_id("chkOpt4").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a6f496589496f09677d6863")#link driver.find_element_by_id("txtOutput0").send_keys("5 4 3 2 1") driver.find_element_by_id("txtOutput1").send_keys("3 3 2 2 1 1") driver.find_element_by_id("txtOutput2").send_keys("6 5 2 3 4") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a6f49d489496f09677d686d")#link driver.find_element_by_id("chkOpt2").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a6f4ac489496f09677d688c")#link driver.find_element_by_id("chkOpt2").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a6f4b5389496f09677d68a0")#link driver.find_element_by_id("chkOpt3").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a6f4cc589496f09677d68c6")#link driver.find_element_by_id("chkOpt2").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a6f4d4489496f09677d68ca")#link driver.find_element_by_id("chkOpt2").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a6f4dca89496f09677d68d4")#link driver.find_element_by_id("chkOpt2").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) # c1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a71b9a389496f09677d88a7")#link t = driver.find_elements_by_class_name("CodeMirror-code") t[1].click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" /* struct Node { int data; struct Node *next; struct Node *prev; }; Above structure is used to define the linked list, You have to complete the below functions only */ void swapNodes(Node** head, int x, int y){ if(x == y){ return; } Node *prevX = NULL , *currX = *head; while (currX && currX->data != x) { prevX = currX; currX = currX->next; } Node *prevY = NULL , *currY = *head; while (currY && currY->data != y) { prevY = currY; currY = currY->next; } if(currX == NULL || currY == NULL){ return; } if(prevX != NULL){ prevX->next = currY; } else{ *head = currY; } if(prevY != NULL){ prevY->next = currX; } else{ *head = currX; } Node *temp = currY->next; currY->next = currX->next; currX->next = temp; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c2 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a71d09b89496f09677d8d92")#link t = driver.find_elements_by_class_name("CodeMirror-code") t[1].click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" /* struct Node { int data; Node *next; Node *prev; }; Above structure is used to define the linked list, You have to complete the below functions only */ void insertAtBeg(Node **head , int data){ Node *node = new Node(data); node->data = data; node->next = *head; node->prev = NULL; if(head != NULL){ (*head)->prev = node; } *head = node; } int deleteAtEnd(Node *head){ Node *last = head; while (last->next != NULL) { last = last->next; } int x = last->data; last->prev->next = NULL; delete(last); return x; } Node* rotateByK(Node* head, int k) { if(head == NULL){ return head; } for (int i = 0; i < k; i++) { int x = deleteAtEnd(head); insertAtBeg(&head,x); } return head; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a71d13989496f09677d8d9d")#link t = driver.find_elements_by_class_name("CodeMirror-code") t[1].click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" /* struct Node { int data; Node *next; Node *prev; }; Above structure is used to define the linked list, You have to complete the below functions only */ Node* rearrangeList(Node* head){ int i = 1; Node *even = NULL; Node *odd = NULL; Node *last = head; while (last != NULL) { if(i%2 == 0){ even = insertEnd(even , last->data); } if(i%2 != 0){ odd = insertEnd(odd , last->data); } last = last->next; i++; } Node *final = NULL; while (even != NULL) { final = insertEnd(final , even->data); even = even->next; } while (odd != NULL) { final = insertEnd(final , odd->data); odd = odd->next; } return final; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) ######################################################################333333 driver.get("https://codequotient.com/attempt/attempttutorial/60d991baccde02f820596293/5a6346f9e2509a3288171d86") button = driver.find_elements_by_xpath("//a[text()='run']") driver.execute_script("arguments[0].click();",button[0]) time.sleep(2); driver.execute_script("arguments[0].click();",button[1]) time.sleep(2) #MCQ5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a6f4e8389496f09677d68eb")#link driver.find_element_by_id("chkOpt2").click()# driver.find_element_by_id("executeMCQ").click()#Submit Button time.sleep(2) # MCQ3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a6f4f0a89496f09677d68f2")#link driver.find_element_by_id("txtOutput0").send_keys("5") driver.find_element_by_id("txtOutput1").send_keys("4") driver.find_element_by_id("txtOutput2").send_keys("5") WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(3) # c1 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a7593d2a0bdb04eb16c3c04")#link t = driver.find_elements_by_class_name("CodeMirror-code") t[1].click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" /* struct Node { int data; struct Node* next; }; Above structure is used to define the linked list, You have to complete the below functions only */ int isCircular(Node* head){ if(head == NULL){ return 1; } Node *node = head->next; while (node != head && node != NULL) { node = node->next; } return (node == head); } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c2 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a759518a0bdb04eb16c3c0f")#link t = driver.find_elements_by_class_name("CodeMirror-code") t[1].click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" /* struct Node { int data; Node* next; }; Above structure is used to define the linked list, You have to complete the below functions only */ Node* insertBeg(Node* head, int data){ Node *ptr = new Node(); ptr->data = data; ptr->next = NULL; Node *temp ; if(ptr == NULL){ cout<<endl; printf("OVERFLOW"); } else{ if(head == NULL){ head = ptr; ptr->next = head; } else{ temp = head; while (temp->next != head) { temp = temp->next; } ptr->next = head; temp->next = ptr; head = ptr; } } return head; } Node* insertEnd(Node* head, int data){ Node *ptr = new Node(); ptr->data = data; ptr->next = NULL; Node *temp ; if(ptr == NULL){ cout<<endl; printf("OVERFLOW"); } else{ if(head == NULL){ head = ptr; ptr->next = head; } else{ temp = head; while (temp->next != head) { temp = temp->next; } temp->next = ptr; ptr->next = head; return head; } } } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c3 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a7595baa0bdb04eb16c3c19")#link t = driver.find_elements_by_class_name("CodeMirror-code") t[1].click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" /* struct Node { int data; Node* next; }; Above structure is used to define the linked list, You have to complete the below functions only */ Node* deleteBeg(Node* head){ Node *p = head; while (p->next != head) { p = p->next; } p->next = head->next; int x = head->data; delete head; head = p->next; return head; } Node* deleteEnd(Node* head){ Node *p = head; while (p->next->next != head) { p = p->next; } Node *q = p->next; p->next = head; delete q; return head; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c4 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a75964aa0bdb04eb16c3c20")#link t = driver.find_elements_by_class_name("CodeMirror-code") t[1].click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" /* struct Node { int data; Node* next; }; Above structure is used to define the linked list, You have to complete the below functions only */ int countNodes(Node* head){ int length = 0; if(head == NULL){ return 0; } Node *p = head; while (p->next != head) { length++; p = p->next; } return length+1; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c5 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a7597cfa0bdb04eb16c3c26")#link t = driver.find_elements_by_class_name("CodeMirror-code") t[1].click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" /* struct Node { int data; struct Node* next; }; Above structure is used to define the linked list, You have to complete the below functions only */ void sortedInsert(Node **head , Node *newN){ Node *current = *head; if(current == NULL){ newN->next = newN; *head = newN; } else if(current->data >= newN->data){ /* If value is smaller than head's value then we need to change next of last node */ *head = insertBeg(*head , newN->data); } else{ /* Locate the node before the point of insertion */ while (current->next != *head && current->next->data < newN->data) { current = current->next; } newN->next = current->next; current->next = newN; } } Node* insertSorted(Node* head , int k){ Node *ptr = new Node(); ptr->data = k; sortedInsert(&head ,ptr); return head; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2) # c6 driver.get("https://codequotient.com/attempt/attemptquestion/60d991baccde02f820596293/5a759729a0bdb04eb16c3c23")#link t = driver.find_elements_by_class_name("CodeMirror-code") t[1].click() time.sleep(2) pyautogui.hotkey('ctrl', 'a') pyperclip.copy(""" /* struct Node { int data; struct Node* next; }; Above structure is used to define the linked list, You have to complete the below functions only */ Node* listCut(Node* head){ Node *head1=NULL; Node *head2=NULL; Node *temp1=head; Node *temp2=head; if(head==NULL) return 0; while(temp2->next!=head && temp2->next->next!=head){ temp2=temp2->next->next; temp1=temp1->next; } if(temp2->next->next==head) temp2=temp2->next; head1=head; if(head->next!=head) head2=temp1->next; temp2->next=temp1->next; temp1->next=head; return head1,head2; } """) pyautogui.hotkey('ctrl', 'v') WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "executeProgram"))).click()#Submit Button time.sleep(2)
[ "noreply@github.com" ]
Hiten1502.noreply@github.com
20906b867a86191964ed50bf89e46d6cea287b00
742e4ba2a554b1d37c84190ae0ed8b271e4671ab
/plot_service/settings.py
2b63e35391b5682a34247ef962c84b9a743d8b3e
[]
no_license
xiaoxuwu/chpr-plot-service
ebbfd6be545679d5b5e7c1602ca88136b057e9a4
1cde0ee3e9dfd6aa48f06ff68b268b5a03f72b63
refs/heads/master
2020-05-09T16:17:21.135337
2019-05-31T08:59:55
2019-05-31T08:59:55
181,265,500
0
0
null
2019-05-31T18:02:59
2019-04-14T05:43:01
JavaScript
UTF-8
Python
false
false
3,543
py
""" Django settings for plot_service project. Generated by 'django-admin startproject' using Django 2.1.7. For more information on this file, see https://docs.djangoproject.com/en/2.1/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/2.1/ref/settings/ """ import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'k583or_5w=^bw1b8sb9er^&2(+3br@*c^_0p61jzgkygg+dfk(' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = ['*'] # Application definition INSTALLED_APPS = [ 'internal.apps.InternalConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django_cleanup', ] 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 = 'plot_service.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'plot_service.wsgi.application' # Database # https://docs.djangoproject.com/en/2.1/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'postgres', 'USER': 'postgres', 'PASSWORD': 'Us7JdibopXhaLRScZIIplUOzv9HcWzz5', 'HOST': 'db', 'PORT': 5432, } } # Password validation # https://docs.djangoproject.com/en/2.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/2.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/2.1/howto/static-files/ STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), ) ENV_PATH = os.path.abspath(os.path.dirname(__file__)) MEDIA_ROOT = os.path.join(ENV_PATH, 'media/') # Admin ADMIN_SITE_HEADER = "CHPR Plot Service Management"
[ "carter.wu@ucla.edu" ]
carter.wu@ucla.edu
5f32f8cc6cbabc1059e03e1779cf94d2f294fd76
9cb7debe213e40b87833076f944ccd01d83ab2d9
/pywick/models/segmentation/testnets/exfuse/__init__.py
f05a4cf8d911693123d7967bd1352fbd13083569
[ "MIT", "BSD-3-Clause", "Apache-2.0", "BSD-2-Clause" ]
permissive
csetraynor/pywick
7c580eb46cc48a0d7d92acd7f770079a37c84304
9d663faf0c1660a9b8359a6472c164f658dfc8cb
refs/heads/master
2023-08-21T06:25:05.197965
2021-10-22T03:09:17
2021-10-22T03:09:17
null
0
0
null
null
null
null
UTF-8
Python
false
false
65
py
""" Source: https://github.com/rplab-snu/nucleus_segmentation """
[ "Alexei.Samoylov@digikey.com" ]
Alexei.Samoylov@digikey.com
ab464f58e95e506c9fba97a806bf99379fd6ff5a
0f58a177cdecbbabc276fd8c2dd7ffe7d53c189d
/Random_Week_image_resize.py
a88eff88d74e1217e1be1a8968c66529ea7710d6
[]
no_license
tianpei2/Trips_Time-series
60e5f30aa5856f9cdf1709342c58d1c25f46a6c4
da0371668fe7ca73fe8e485cd8aa094bbbd294cf
refs/heads/master
2020-05-26T15:22:55.459189
2018-10-01T15:10:09
2018-10-01T15:10:09
85,010,100
1
0
null
null
null
null
UTF-8
Python
false
false
386
py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Apr 15 22:01:58 2017 @author: wangtianpei """ dir_path = "/Users/wangtianpei/Desktop/Random_Week/" import PIL from PIL import Image for i in range(671): image = Image.open(dir_path+'flow_{}.png'.format(i)) img = image.resize((2100,1290), PIL.Image.ANTIALIAS) img.save(dir_path+'flow_test_{}.png'.format(i))
[ "tianpei3@gmail.com" ]
tianpei3@gmail.com
dc2303b686f9974a1137610564beb7dceee97b9d
4eb22dce382fe3465a58a9f43ea60322b1e0326f
/crab/crab_mc.py
046f65fab295fa5b8fdbe659e93c5b883874c9cf
[]
no_license
leonardogiannini/vhbb-nano
a64bc18e50ba88b97bce5a9182d1673607a37d3b
6ef8210faca0aeaba0857db5c41a59cdf4ebd10b
refs/heads/master
2021-04-03T06:27:25.618867
2018-03-14T20:40:12
2018-03-14T20:40:12
124,595,678
0
0
null
2018-03-09T21:33:25
2018-03-09T21:33:24
null
UTF-8
Python
false
false
2,024
py
import sys from CRABClient.UserUtilities import config, getUsernameFromSiteDB config = config() config.General.requestName = 'VHbbPostNano2016_V1' config.General.workArea = 'crab_projects' config.General.transferOutputs = True config.General.transferLogs = True config.JobType.pluginName = 'Analysis' config.JobType.psetName = 'PSet.py' config.JobType.scriptExe = 'crab_script.sh' config.JobType.inputFiles = ['../keep_and_drop.txt','../postproc.py','../../../../../../scripts/haddnano.py'] #hadd nano will not be needed once nano tools are in cmssw config.JobType.sendPythonFolder = True config.Data.inputDataset = '/TT_TuneCUETP8M2T4_13TeV-powheg-pythia8/RunIISummer16MiniAODv2-PUMoriond17_80X_mcRun2_asymptotic_2016_TrancheIV_v6-v1/MINIAODSIM' config.Data.inputDBS = 'global' config.Data.splitting = 'EventAwareLumiBased' config.Data.outLFNDirBase = '/store/user/%s/VHbbPostNano2016_V1/' % (getUsernameFromSiteDB()) config.Data.publication = True #config.Data.outputDatasetTag = 'RunIISummer17MiniAOD-92X-NanoCrabProd006' config.Data.outputDatasetTag = 'RunIISummer16MiniAODv2-PUMoriond17-80X-VHbbPostNano2016_V1' config.Data.allowNonValidInputDataset = True config.Site.storageSite = 'T2_CH_CERN' #sites=['T2_IT_Legnaro','T2_IT_Bari','T2_IT_Pisa','T2_CH_CERN'] sites=['T2_CH_CERN'] if __name__ == '__main__': f=open(sys.argv[1]) content = f.readlines() content = [x.strip() for x in content] from CRABAPI.RawCommand import crabCommand n=79 for dataset in content : #site=sites[n%4] #config.Site.storageSite=site #if site=='T2_CH_CERN' : # config.Data.outLFNDirBase= '/store/group/cmst3/group/nanoAOD/NanoTestProd006' #else : # config.Data.outLFNDirBase = '/store/user/%s/NanoTestProd006/' % (getUsernameFromSiteDB()) config.Data.inputDataset = dataset config.Data.unitsPerJob = 2000000 n+=1 nnn="%s"%n config.General.requestName = "VHbbPostNano2016_V1"+dataset.split('/')[1][:30]+dataset.split('/')[2][:30]+nnn crabCommand('submit', config = config)
[ "stephane.b.cooperstein@cern.ch" ]
stephane.b.cooperstein@cern.ch
9218806546d7b9ce9b66dcbbc82107ef7c032296
2f1f742ae400da451c2f92348d7d40b21afb245d
/sender.py
03c7d5322c5e93f265739a48af10fd159529f5db
[]
no_license
Plocatel/Speech_Fitt
869b14e580bb6a4035bb48df8f37ee3d22be4737
2ad272205d6acdb8253270eac38e25fbf2232871
refs/heads/master
2021-01-20T22:34:20.488270
2013-06-25T12:52:09
2013-06-25T12:52:09
null
0
0
null
null
null
null
UTF-8
Python
false
false
649
py
#!/usr/bin/python #-*-coding:utf8-*- from PyQt4.QtGui import * from PyQt4.QtCore import * import sys import subprocess class Sender(QThread): def __init__(self,id_): QThread.__init__(self) self.index = "-1" self.id_ = id_ def __del__(self): self.wait() def run(self): #print "[",self.id_,"] send : ",self.index p=subprocess.Popen(["./send.sh",str(self.index)],stdout=subprocess.PIPE,stderr=subprocess.STDOUT) line = unicode(p.stdout.readline(), "utf-8") self.emit(SIGNAL("understand"),line) def analyse(self,index): self.index = index self.start()
[ "locap25@gmail.com" ]
locap25@gmail.com
490a1cd0f8b919fe42e8ad8ef3ee418b8a65231c
712a10965421313f657511af645f238603eab7fb
/appium_practice_3/Base/get_driver.py
b5e0e24cbc1ac7fce7ff01e06b47084a0af74ca6
[]
no_license
ahahayaya/appium_practice
cd3725d413fc9bbb1bf7221271a99790bcefa974
1e0684e2eb395ae7350df477b9841b3960087a73
refs/heads/master
2021-03-25T12:48:28.729542
2020-03-16T05:43:49
2020-03-16T05:43:49
247,619,730
0
0
null
null
null
null
UTF-8
Python
false
false
316
py
from appium import webdriver def get_driver(): desired_caps={} desired_caps['platformName']='Android' desired_caps['deviceName']='xx' desired_caps['appPackage']='com.android.settings' desired_caps['appActivity']='.Settings' return webdriver.Remote('http://127.0.0.1:4723/wd/hub',desired_caps)
[ "hi_emily_wu@163.com" ]
hi_emily_wu@163.com
e6a83c95528d8511ff90cfc2aad4b010e8c95dc2
f089a503eba0a93430fc9ab2d877a1b9b99f3182
/Kontrola_Danych.py
c8e744794141a46c5c24b2d5249999624c7b3380
[ "MIT" ]
permissive
bDOT666/Statystycznie
7678cf42a4f4e4bd81221cc4cf0814be42f35650
945a52568be764105f716c083eac89da176396aa
refs/heads/master
2020-12-20T13:41:52.092265
2020-03-09T20:58:53
2020-03-09T20:58:53
236,095,568
0
0
null
null
null
null
UTF-8
Python
false
false
17,391
py
import csv import tkinter from tkinter import messagebox as msb from tkinter import scrolledtext from tkinter.filedialog import * import scipy.stats as stats import pandas as pd import numpy as np import math as mat from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg from matplotlib.figure import Figure import matplotlib matplotlib.use('TkAgg') # # # ------------- KONTROLA DANYCH -------------- # # slownik = {} lista_boxow =[] def wczytaj_plik(scierzeka, przycisk_1, przycisk_2): global lista fc = tkinter.filedialog.askopenfilename( initialdir='/', title='Wybierz plik csv', filetypes=[('text files', '.csv')]) f = open(fc, 'r') dialect = csv.Sniffer().sniff(f.read(1024), delimiters=";, ") f.seek(0) reader = csv.reader(f, dialect) lista = list(reader) lista = np.array(lista) scierzeka.config(text=fc) odpal(przycisk_1) odpal(przycisk_2) class WybieranieKolumn(tkinter.Tk): def __init__(self, *args, **kwargs): tkinter.Tk.__init__(self, *args, **kwargs) self.resizable(width=False, height=False) # ustawienie frame4 = Frame(self) frame5 = Frame(self) frame6 = Frame(self) frame7 = Frame(self) frame8 = Frame(self) frame9 = Frame(self) frame10 = Frame(self) frame4.grid(row=1, column=0, rowspan=5, sticky=W + E) frame5.grid(row=1, column=2, rowspan=5, sticky=W + E) frame6.grid(row=6, column=2, sticky=W + E) frame7.grid(row=1, column=1, sticky=W + E) frame8.grid(row=2, column=1, sticky=W + E) frame9.grid(row=4, column=1, sticky=W + E) frame10.grid(row=5, column=1, sticky=W + E) # lista z tego pobieram self.Rama1 = tkinter.Frame(frame4) self.Pasek = tkinter.Scrollbar(self.Rama1) self.ListaBox = tkinter.Listbox(self.Rama1) self.ListaBox.delete(0, tkinter.END) for i in range(len(lista[0])): self.ListaBox.insert(tkinter.END, lista[0, i]) self.Pasek['command'] = self.ListaBox.yview self.ListaBox['yscrollcommand'] = self.Pasek.set self.ListaBox.bind('<<ListboxSelect>>') # Lista do tego pobieram i przyciski self.Rama2 = tkinter.Frame(frame5) self.Pasek2 = tkinter.Scrollbar(self.Rama2) self.ListaBox2 = tkinter.Listbox(self.Rama2) self.Pasek2['command'] = self.ListaBox2.yview self.ListaBox2['yscrollcommand'] = self.Pasek2.set self.ListaBox2.bind('<<ListboxSelect>>') self.B_wybor = tkinter.Button(frame6, text='OK', command=self.wyjmij_z_listy) self.B_jedna_plus = tkinter.Button(frame7, text='>', command=self.daj_jedno) self.B_wszystkie_plus = tkinter.Button(frame8, text='>>', command=self.dodaj_wszystki) self.B_jedna_minus = tkinter.Button(frame9, text='< ', command=self.usun_jedno) self.B_wszystkie_minus = tkinter.Button(frame10, text='<< ', command=self.usun_wszystki) # packi self.Rama1.pack() self.Pasek.pack(side=tkinter.RIGHT, fill=tkinter.Y) self.ListaBox.pack(side=tkinter.LEFT, fill=tkinter.Y) self.Rama2.pack() self.Pasek2.pack(side=tkinter.RIGHT, fill=tkinter.Y) self.ListaBox2.pack(side=tkinter.LEFT, fill=tkinter.Y) self.B_wybor.pack() self.B_jedna_plus.pack() self.B_wszystkie_plus.pack() self.B_jedna_minus.pack() self.B_wszystkie_minus.pack() def daj_jedno(self): a = str((self.ListaBox.get(self.ListaBox.curselection()))) self.ListaBox2.insert(tkinter.END, a) def dodaj_wszystki(self): self.ListaBox2.delete(0, tkinter.END) for i in range(len(lista[0])): self.ListaBox2.insert(tkinter.END, lista[0, i]) def usun_jedno(self): self.ListaBox2.delete(tkinter.ANCHOR) def usun_wszystki(self): self.ListaBox2.delete(0, tkinter.END) def wyjmij_z_listy(self): global wybrane_kolumny wybrane_kolumny = list(self.ListaBox2.get(0, tkinter.END)) # Aktywoj.config(state="normal") self.destroy() def wybierz_kolumny(): klasa_kolumny = WybieranieKolumn() klasa_kolumny.mainloop() def zatwierdz_kolumny(przycisk_1, przycisk_2): global Nowa_lista global Naglowki Nowa_lista = np.empty([len(lista), 0]) ii = 0 while ii < len(wybrane_kolumny): a = wybrane_kolumny[ii] for i, j in enumerate(lista[0]): if j == a: Nowa_lista = np.append(Nowa_lista, lista[:, i:i + 1], axis=1) ii = ii + 1 Naglowki = Nowa_lista[0] try: Nowa_lista = Nowa_lista.astype(np.float) except: try: Nowa_lista = Nowa_lista[1:len(Nowa_lista), :].astype(np.float) except: Nowa_lista = np.char.replace(Nowa_lista, ',', '.') try: Nowa_lista = Nowa_lista.astype(np.float) except: try: Nowa_lista = Nowa_lista[1:len(Nowa_lista), :].astype(np.float) except: msb.showinfo("Uwaga!", "Wybrane kolumny zawierają dane tekstowe!\nWybierz inne kolumny!") odpal(przycisk_1) odpal(przycisk_2) print(Naglowki) def wybierz_do_wypisania(dane, okno, ile_wierszy): for x in range(len(dane[0])): for y in range(ile_wierszy): wez = tkinter.StringVar(okno) pokaz = tkinter.Label(okno, textvariable=wez) a = dane[y, x] wez.set(a) pokaz.grid(row=y, column=x) class PodgladWybrane(tkinter.Tk): def __init__(self, *args, **kwargs): tkinter.Tk.__init__(self, *args, **kwargs) self.resizable(width=False, height=False) if len(Nowa_lista[:, 0]) > 20: wybierz_do_wypisania(Nowa_lista, self, 20) else: wybierz_do_wypisania(Nowa_lista, self, len(Nowa_lista[:, 0])) def podglad_kolumn(): klasa_wyniki = PodgladWybrane() klasa_wyniki.mainloop() class PodgladWszystko(tkinter.Tk): def __init__(self, *args, **kwargs): tkinter.Tk.__init__(self, *args, **kwargs) self.resizable(width=False, height=False) if len(Nowa_lista[:, 0]) > 20: wybierz_do_wypisania(lista, self, 20) else: wybierz_do_wypisania(lista, self, len(lista[:, 0])) def podglad_wszystko(): wyswietl_wszystko = PodgladWszystko() wyswietl_wszystko.mainloop() def zapis_pliku(): save = pd.DataFrame(data=Nowa_lista) files = [('csv', '*.csv')] file_name = asksaveasfilename(filetypes=files, defaultextension=files) if file_name: save.to_csv(file_name, sep=';', encoding='utf-8-sig') def notatnik(): okno = Tk() okno.title("Notatki") okno.geometry('350x810') notatki = scrolledtext.ScrolledText(okno, width=40, height=50) notatki.grid(column=0, row=0) okno.mainloop() # # """ # ------------- WSPEIRAJĄCE -------------- """ # # def odpal(tabela): tabela.config(state="normal") def utworz_dataframe(dane, index, columny): np_w = np.array(dane) return pd.DataFrame(data=np_w, index=index, columns=columny) def tworzenie_tabel_w_petli(dane, okno, poziom): if poziom == 'True': for x in range(len(dane)): wez = tkinter.StringVar(okno) pokaz = tkinter.Label(okno, textvariable=wez) a = dane[x] wez.set(a) pokaz.grid(row=1, column=x + 2) else: for y in range(len(dane)): wez = tkinter.StringVar(okno) pokaz = tkinter.Label(okno, textvariable=wez) a = dane[y] wez.set(a) pokaz.grid(row=y + 2, column=1) def wypelanianie_tabeli_w_petli(dlugosc, okno, x): for y in range(dlugosc): okno.b2 = tkinter.Text(okno, width=10, height=1) okno.b2.insert('end', okno.Wyniki[y]) okno.b2.config(state="disabled") okno.b2.grid(row=y + 2, column=x + 2) def donothig(): pass def donothing(): pass # # """ # Miary Położenia """ # # class MiaryPol(tkinter.Tk): def __init__(self, *args, **kwargs): tkinter.Tk.__init__(self, *args, **kwargs) self.resizable(width=False, height=False) self.funkcje = [ 'Wartość minimalna', 'Wartość maksymalna', 'Średnia arytmetyczna', # 'Średnia geometryczna', 'Średnia harmoniczna', 'Kwartyl dolny', 'Mediana', 'Kwartyl górny'] self.save = [] for x1 in range(len(Nowa_lista[0])): self.Wyniki = [] mini = np.nanmin(Nowa_lista[:, x1]) maxi = np.nanmax(Nowa_lista[:, x1]) sr_a = np.nanmean(Nowa_lista[:, x1]) # sr_g = stat.geometric_mean(Nowa_lista[:, x1]) sr_h = stats.hmean(Nowa_lista[:, x1], axis=0, dtype=None) kw_d = np.nanquantile(Nowa_lista[:, x1], q=0.25) med = np.nanmedian(np.sort(Nowa_lista[:, x1])) kw_g = np.nanquantile(Nowa_lista[:, x1], q=0.75) self.Wyniki.append(mini) self.Wyniki.append(maxi) self.Wyniki.append(sr_a) # self.Wyniki.append(sr_g) self.Wyniki.append(sr_h) self.Wyniki.append(kw_d) self.Wyniki.append(med) self.Wyniki.append(kw_g) self.save.append(self.Wyniki) wypelanianie_tabeli_w_petli(len(self.funkcje), self, x1) tworzenie_tabel_w_petli(Naglowki, self, poziom='True') tworzenie_tabel_w_petli(self.funkcje, self, poziom='False') self.l1 = Button(self, text='Zapisz wyniki', command=self.zapisz) self.l1.grid(row=len(self.funkcje) + 3, column=len(Nowa_lista[0]) + 1, pady=10, sticky=W) self.wolny = Label(self, text=' ', padx=10, pady=10) self.wolny.grid(row=len(self.funkcje) + 3, column=len(Nowa_lista[0]) + 3) def zapisz(self): files = [('csv', '*.csv')] file_name = asksaveasfilename(filetypes=files, defaultextension=files) if file_name: utworz_dataframe(self.save, Naglowki, self.funkcje).to_csv(file_name, sep=';', encoding='utf-8-sig') def miary_polozenia(): klasa_wyniki = MiaryPol() klasa_wyniki.mainloop() class MiaryZmi(tkinter.Tk): def __init__(self, *args, **kwargs): tkinter.Tk.__init__(self, *args, **kwargs) self.resizable(width=False, height=False) self.funkcje = ( 'Wariancja', 'Odchylenie standardowe', 'Odchylenie przeciętne', 'Klasyczny współczynnik zmienności', 'Rozstęp', 'Rozstęp międzykwartylowy', 'Odchylenie ćwiartkowe', 'Pozycyjny współczynnik zmienności') self.save = [] for x1 in range(len(Nowa_lista[0])): self.Wyniki = [] war = float(np.nanvar(Nowa_lista[:, x1])) odch_s = np.nanstd(Nowa_lista[:, x1]) suma = 0 for i in range(len(Nowa_lista)): suma = suma + mat.fabs(Nowa_lista[i, x1] - np.nanmean(Nowa_lista[:, x1])) odch_p = suma / len(Nowa_lista[:, x1]) klas_wsp_z = (np.nanstd(Nowa_lista[:, x1]) / np.nanmean(Nowa_lista[:, x1])) * 100 roz = np.ptp(Nowa_lista[:, x1]) roz_m = stats.iqr(Nowa_lista[:, x1]) odch_c = stats.iqr(Nowa_lista[:, x1]) poz_wsp_z = ((stats.iqr(Nowa_lista[:, x1]) / 2) / np.nanmedian(np.sort(Nowa_lista[:, x1]))) * 100 self.Wyniki.append(war) self.Wyniki.append(odch_s) self.Wyniki.append(odch_p) self.Wyniki.append(klas_wsp_z) self.Wyniki.append(roz) self.Wyniki.append(roz_m) self.Wyniki.append(odch_c) self.Wyniki.append(poz_wsp_z) self.save.append(self.Wyniki) wypelanianie_tabeli_w_petli(len(self.funkcje), self, x1) tworzenie_tabel_w_petli(Naglowki, self, poziom='True') tworzenie_tabel_w_petli(self.funkcje, self, poziom='False') self.l1 = Button(self, text='Zapisz wyniki', command=self.zapisz) self.l1.grid(row=len(self.funkcje) + 3, column=len(Nowa_lista[0]) + 1, pady=10, sticky=W) self.wolny = Label(self, text=' ', padx=10, pady=10) self.wolny.grid(row=len(self.funkcje) + 3, column=len(Nowa_lista[0]) + 3) def zapisz(self): files = [('csv', '*.csv')] file_name = asksaveasfilename(filetypes=files, defaultextension=files) if file_name: utworz_dataframe(self.save, Naglowki, self.funkcje).to_csv(file_name, sep=';', encoding='utf-8-sig') def miary_zmiennosci(): klasa_wyniki = MiaryZmi() klasa_wyniki.mainloop() def kappa(): pass class MiaryAsy(tkinter.Tk): def __init__(self, *args, **kwargs): tkinter.Tk.__init__(self, *args, **kwargs) self.resizable(width=False, height=False) self.funkcje = ('Wskaźnik skośności', 'Pozycyjny wskaźnik skośności', 'Pozycyjny współczynnik asymetrii', 'Klasyczny współczynnik asymetrii', 'Współczynnik kurtozy', 'Współczynnik ekscesu') self.save = [] for x1 in range(len(Nowa_lista[0])): sko = stats.skew(Nowa_lista[:, x1]) y = np.sort(Nowa_lista[:, x1]) poz_sko = np.nanquantile(y, q=0.75) + np.nanquantile(y, q=0.25) - 2 * (np.nanmedian(y)) poz_asy = poz_sko / (np.nanquantile(y, q=0.75) - np.nanquantile(y, q=0.25)) mean = np.nanmean(Nowa_lista[:, x1]) a = 0 for i in range(len(Nowa_lista[:, x1])): a = a + ((Nowa_lista[i, x1] - mean) ** 3) m3 = a / len(Nowa_lista[:, x1]) kla_asy = m3 / (np.nanstd(Nowa_lista[:, x1]) ** 3) kurtoza = stats.kurtosis(Nowa_lista[:, x1], axis=0, fisher=False) k1 = (stats.kurtosis(Nowa_lista[:, x1], axis=0, fisher=False)) - 3 self.Wyniki = [] self.Wyniki.append(sko) self.Wyniki.append(poz_sko) self.Wyniki.append(poz_asy) self.Wyniki.append(kla_asy) self.Wyniki.append(kurtoza) self.Wyniki.append(k1) self.save.append(self.Wyniki) wypelanianie_tabeli_w_petli(len(self.funkcje), self, x1) tworzenie_tabel_w_petli(Naglowki, self, poziom='True') tworzenie_tabel_w_petli(self.funkcje, self, poziom='False') self.l1 = Button(self, text='Zapisz wyniki', command=self.zapisz) self.l1.grid(row=len(self.funkcje) + 3, column=len(Nowa_lista[0]) + 1, pady=10, sticky=W) self.wolny = Label(self, text=' ', padx=10, pady=10) self.wolny.grid(row=len(self.funkcje) + 3, column=len(Nowa_lista[0]) + 3) def zapisz(self): files = [('csv', '*.csv')] file_name = asksaveasfilename(filetypes=files, defaultextension=files) if file_name: utworz_dataframe(self.save, Naglowki, self.funkcje).to_csv(file_name, sep=';', encoding='utf-8-sig') def miary_asymetrii(): klasa_wyniki = MiaryAsy() klasa_wyniki.mainloop() def kor_per(): pass def kow(): pass def kor_sper(): pass def reg_lin(): pass def reg_wyk(): pass def reg_kwadt(): pass # # """ # Wykresy """ # # def kolumny_do_wykresow(ram2): slownik.clear() for cb in lista_boxow: cb.destroy() lista_boxow.clear() for kolumna in Naglowki: slownik[kolumna] = tkinter.IntVar() c = tkinter.Checkbutton(ram2, text=kolumna, variable=slownik[kolumna]) c.pack() lista_boxow.append(c) def wyjmij_kolumny_wykresy(): do_wykresu = [] zmienne = [] for key, value in slownik.items(): if value.get() > 0: i = Naglowki.tolist().index(key) zmienne.append(i) print(i) print(key) for i in zmienne: do_wykresu.append(Nowa_lista[:, i]) return do_wykresu def konwertuj_przed_wykresem(): do_wykresu = wyjmij_kolumny_wykresy() do_wykresu = np.array(do_wykresu) do_wykresu = do_wykresu.astype(np.float) return do_wykresu def rysuj_wykres(e1, e2, e3): do_wykresu = konwertuj_przed_wykresem() # W tym miejscu masz wyjęte wybrane wcześniej kolumny # 'do_wykresu' to array z tymi wybranymi kolumnami # ich liczba nie musi sięzgadzać, ale jak zrobisz samo wywolywanie wykresow to dodadm obostrzenie, żeby błąd # wyskakiwał i podawał zakres ile możesz kolumn wybrać do danego wykresu nazwa_wykres = e1.get() nazwa_x = e2.get() nazwa_y = e3.get() v = do_wykresu[0] p = do_wykresu[1] fig = Figure() ax = fig.add_subplot(111) ax.plot(v, color='#4285F4', linewidth=0.51) ax.plot(p, color='#DB4437', linewidth=0.51) ax.invert_yaxis() ax.set_title(nazwa_wykres, fontsize=16) ax.set_ylabel(nazwa_x, fontsize=14) ax.set_xlabel(nazwa_y, fontsize=14) rysuj = Toplevel() canvas = FigureCanvasTkAgg(fig, master=rysuj) canvas.get_tk_widget().pack() canvas.draw()
[ "mateusz.zietara8721@gmail.com" ]
mateusz.zietara8721@gmail.com
7626a80f9dde988d8c40de3c64cf0d0275550f31
2b353f42255531c9cd67fce3f5336003c814d21e
/src/music/migrations/0002_auto_20191108_1659.py
13731103061be33085f244deb96448e446a0fb7d
[]
no_license
14DENDIK/spot-music-app
469ce550d47ceb06108d886b146f759b063a1c55
1d69cbf0da9e223b1610bf94d27d8fbf96ce7408
refs/heads/master
2020-09-22T01:54:12.486762
2019-11-30T12:41:05
2019-11-30T12:41:05
225,008,375
0
0
null
null
null
null
UTF-8
Python
false
false
405
py
# Generated by Django 2.2.7 on 2019-11-08 16:59 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('music', '0001_initial'), ] operations = [ migrations.AlterField( model_name='album', name='image', field=models.FileField(default='default.jpg', upload_to='album_images'), ), ]
[ "sardor.mukhitdinov98@gmail.com" ]
sardor.mukhitdinov98@gmail.com
5a86e8439e4dd2f1d28803f2b0512fcc534d073f
eca77bc8d84f6011305e5c19463f3477ce7318fc
/python/tightWenuSelectionVBTFrelPFIsolation_cfi.py
39cc0026aa8c42345d6ea51aa822eca86ede295c
[]
no_license
cms-analysis/TauAnalysis-Skimming
140e13a611a017e04c05675aeb02b29bbd11fc9f
77bf75c5ce9b4232cb6dec1097c6459b5c5270d9
refs/heads/master
2020-12-24T14:09:49.225323
2013-06-28T20:10:44
2013-06-28T20:10:44
null
0
0
null
null
null
null
UTF-8
Python
false
false
12,050
py
import FWCore.ParameterSet.Config as cms import copy from PhysicsTools.PatAlgos.tools.coreTools import * from PhysicsTools.PatAlgos.tools.jetTools import * from PhysicsTools.PatUtils.tools.metUncertaintyTools import runMEtUncertainties #-------------------------------------------------------------------------------- # Selection of W --> e nu candidate events passing VTBF selection # documented in CMS PAS EWK-10-005 #-------------------------------------------------------------------------------- def filterTightWenuCandidates(process, isMC): process.tightWenuSelectionSequence = cms.Sequence() # Trigger requirements process.load("HLTrigger.HLTfilters.hltHighLevel_cfi") process.wenuHLTFilter = process.hltHighLevel.clone( TriggerResultsTag = cms.InputTag("TriggerResults", "", "HLT"), HLTPaths = cms.vstring([ # single electron triggers (2011 Run B) 'HLT_Ele32_CaloIdVT_CaloIsoT_TrkIdT_TrkIsoT_v7', 'HLT_Ele25_CaloIdL_CaloIsoVL_TrkIdVL_TrkIsoVL_v5', # single electron triggers (Summer'11 MC) 'HLT_Ele32_CaloIdVT_CaloIsoT_TrkIdT_TrkIsoT_v1', 'HLT_Ele27_CaloIdVT_CaloIsoT_TrkIdT_TrkIsoT_v2', ]), throw = cms.bool(False) ) process.tightWenuSelectionSequence += process.wenuHLTFilter # Vertex selection process.goodVertex = cms.EDFilter("VertexSelector", src = cms.InputTag("offlinePrimaryVertices"), cut = cms.string("isValid & ndof >= 4 & abs(z) < 24 & abs(position.Rho) < 2"), filter = cms.bool(True) ) process.tightWenuSelectionSequence += process.goodVertex process.load("CommonTools.ParticleFlow.pfNoPileUp_cff") process.pfPileUp.Enable = cms.bool(True) process.pfPileUp.checkClosestZVertex = cms.bool(True) process.tightWenuSelectionSequence += process.pfNoPileUpSequence process.load("CommonTools.ParticleFlow.pfParticleSelection_cff") process.tightWenuSelectionSequence += process.pfParticleSelectionSequence process.load("PhysicsTools/PatAlgos/patSequences_cff") # compute electron IsoDeposits process.load("TauAnalysis.Skimming.electronPFIsolationDeposits_cff") process.load("TauAnalysis.Skimming.electronPFIsolationValues_cff") process.electronPFIsolationSequence = cms.Sequence( process.electronPFIsolationDepositsSequence * process.electronPFIsolationValuesSequence ) process.tightWenuSelectionSequence += process.electronPFIsolationSequence # configure pat::Electron production process.patElectrons.isoDeposits = cms.PSet( # CV: strings for IsoDeposits defined in PhysicsTools/PatAlgos/plugins/PATMuonProducer.cc pfChargedHadrons = cms.InputTag("elecPFIsoDepositCharged"), pfNeutralHadrons = cms.InputTag("elecPFIsoDepositNeutral"), pfPhotons = cms.InputTag("elecPFIsoDepositGamma"), user = cms.VInputTag( cms.InputTag("elecPFIsoDepositChargedAll"), cms.InputTag("elecPFIsoDepositPU") ) ) process.patElectrons.userIsolation = cms.PSet( # CV: strings for Isolation values defined in PhysicsTools/PatAlgos/src/MultiIsolator.cc pfChargedHadron = cms.PSet( deltaR = cms.double(0.4), src = process.patElectrons.isoDeposits.pfChargedHadrons, vetos = process.elecPFIsoValueCharged04.deposits[0].vetos, skipDefaultVeto = process.elecPFIsoValueCharged04.deposits[0].skipDefaultVeto ), pfNeutralHadron = cms.PSet( deltaR = cms.double(0.4), src = process.patElectrons.isoDeposits.pfNeutralHadrons, vetos = process.elecPFIsoValueNeutral04.deposits[0].vetos, skipDefaultVeto = process.elecPFIsoValueNeutral04.deposits[0].skipDefaultVeto ), pfGamma = cms.PSet( deltaR = cms.double(0.4), src = process.patElectrons.isoDeposits.pfPhotons, vetos = process.elecEBPFIsoValueGamma04.deposits[0].vetos, skipDefaultVeto = process.elecEBPFIsoValueGamma04.deposits[0].skipDefaultVeto ), user = cms.VPSet( cms.PSet( deltaR = cms.double(0.4), src = process.patElectrons.isoDeposits.user[0], vetos = process.elecEBPFIsoValueChargedAll04.deposits[0].vetos, skipDefaultVeto = process.elecEBPFIsoValueChargedAll04.deposits[0].skipDefaultVeto ), cms.PSet( deltaR = cms.double(0.4), src = process.patElectrons.isoDeposits.user[1], vetos = process.elecPFIsoValuePU04.deposits[0].vetos, skipDefaultVeto = process.elecPFIsoValuePU04.deposits[0].skipDefaultVeto ), cms.PSet( deltaR = cms.double(0.4), src = process.patElectrons.isoDeposits.pfPhotons, vetos = process.elecEEPFIsoValueGamma04.deposits[0].vetos, skipDefaultVeto = process.elecEEPFIsoValueGamma04.deposits[0].skipDefaultVeto ), cms.PSet( deltaR = cms.double(0.4), src = process.patElectrons.isoDeposits.user[0], vetos = process.elecEEPFIsoValueChargedAll04.deposits[0].vetos, skipDefaultVeto = process.elecEEPFIsoValueChargedAll04.deposits[0].skipDefaultVeto ) ) ) process.patElectrons.addGenMatch = cms.bool(False) process.patElectrons.embedHighLevelSelection = cms.bool(True) process.patElectrons.usePV = cms.bool(False) # compute transverse impact parameter wrt. beamspot (not event vertex) if not isMC: # remove MC matching from standard PAT sequences removeMCMatching(process, ["All"], outputInProcess = False) process.patDefaultSequence.remove(process.patJetPartonMatch) # select tight electrons, no isolation cuts applied process.selectedElectronsWP80 = cms.EDFilter("PATElectronSelector", src = cms.InputTag("patElectrons"), cut = cms.string( 'pt > 25 & abs(eta) < 2.1 & ' + \ '(isEB & ' + \ ' sigmaIetaIeta < 0.010 & ' + \ ' deltaPhiSuperClusterTrackAtVtx < 0.06 & deltaEtaSuperClusterTrackAtVtx < 0.004 & ' + \ ' hadronicOverEm < 0.04) | ' + \ '(isEE & ' + \ ' sigmaIetaIeta < 0.030 & ' + \ ' deltaPhiSuperClusterTrackAtVtx < 0.03 & deltaEtaSuperClusterTrackAtVtx < 0.007 & ' + \ ' hadronicOverEm < 0.025)' ), filter = cms.bool(True) ) process.selectedElectronsWP80conversionVeto = cms.EDFilter("NPATElectronConversionFinder", src = cms.InputTag("selectedElectronsWP80"), filter = cms.bool(True) ) # select loose electrons, used for di-electron veto process.selectedElectronsWP95 = cms.EDFilter("PATElectronSelector", src = cms.InputTag("patElectrons"), cut = cms.string( 'pt > 20 & abs(eta) < 2.5 & ' + \ 'gsfTrack.isNonnull & gsfTrack.trackerExpectedHitsInner.numberOfHits <= 1 &' + \ '(isEB & ' + \ ' sigmaIetaIeta < 0.010 & ' + \ ' deltaPhiSuperClusterTrackAtVtx < 0.80 & deltaEtaSuperClusterTrackAtVtx < 0.007 & ' + \ ' hadronicOverEm < 0.15) | ' + \ '(isEE & ' + \ ' sigmaIetaIeta < 0.030 & ' + \ ' deltaPhiSuperClusterTrackAtVtx < 0.70 & deltaEtaSuperClusterTrackAtVtx < 0.010 & ' + \ ' hadronicOverEm < 0.07)' ), filter = cms.bool(False) ) # select tight electrons which are isolated process.selectedIsoElectronsWP80 = cms.EDFilter("PATElectronSelector", src = cms.InputTag("selectedElectronsWP80conversionVeto"), cut = cms.string( '(isEB & ' + \ '(userIsolation("pat::User1Iso")' + \ ' + max(0., userIsolation("pat::PfNeutralHadronIso") + userIsolation("pat::PfGammaIso")' + \ ' - 0.5*userIsolation("pat::User2Iso"))) < 0.06*pt) | ' + \ '(isEE & ' + \ '(userIsolation("pat::User4Iso")' + \ ' + max(0., userIsolation("pat::PfNeutralHadronIso") + userIsolation("pat::User3Iso")' + \ ' - 0.5*userIsolation("pat::User2Iso"))) < 0.06*pt)' ), filter = cms.bool(False) ) process.patDefaultSequence.replace( process.patElectrons, process.patElectrons * process.selectedElectronsWP80 * process.selectedElectronsWP80conversionVeto * process.selectedIsoElectronsWP80 * process.selectedElectronsWP95) # configure pat::Jet production # (enable L2L3Residual corrections in case running on Data) jetCorrections = [ 'L1FastJet', 'L2Relative', 'L3Absolute' ] if not isMC: jetCorrections.append('L2L3Residual') switchJetCollection( process, cms.InputTag('ak5PFJets'), doJTA = True, doBTagging = False, jetCorrLabel = ( 'AK5PF', cms.vstring(jetCorrections) ), doType1MET = False, doJetID = True, jetIdLabel = "ak5", outputModule = '' ) # configure pat::MET production process.load("PhysicsTools.PatUtils.patPFMETCorrections_cff") process.tightWenuSelectionSequence += process.kt6PFJets process.tightWenuSelectionSequence += process.ak5PFJets process.tightWenuSelectionSequence += process.patDefaultSequence doSmearJets = None if isMC: doSmearJets = True else: doSmearJets = False runMEtUncertainties( process, electronCollection = cms.InputTag('selectedIsoElectronsWP80'), photonCollection = '', muonCollection = '', tauCollection = '', jetCollection = cms.InputTag('patJets'), doSmearJets = doSmearJets, addToPatDefaultSequence = False ) if isMC: process.patPFMet.addGenMET = cms.bool(True) process.patPFJetMETtype1p2Corr.jetCorrLabel = cms.string("L3Absolute") process.tightWenuSelectionSequence += process.metUncertaintySequence else: process.patPFMet.addGenMET = cms.bool(False) process.patPFJetMETtype1p2Corr.jetCorrLabel = cms.string("L2L3Residual") process.tightWenuSelectionSequence += process.patJetsNotOverlappingWithLeptonsForMEtUncertainty process.tightWenuSelectionSequence += process.producePatPFMETCorrections # Apply event selection cuts process.isoElectronWP80Filter = cms.EDFilter("CandViewCountFilter", src = cms.InputTag("selectedIsoElectronsWP80"), minNumber = cms.uint32(1) ) process.tightWenuSelectionSequence += process.isoElectronWP80Filter process.diElectronVeto = cms.EDFilter("PATCandViewMaxFilter", src = cms.InputTag("selectedElectronsWP95"), maxNumber = cms.uint32(1) ) process.tightWenuSelectionSequence += process.diElectronVeto process.WenuCandidates = cms.EDProducer("PATElecNuPairProducer", srcVisDecayProducts = cms.InputTag('selectedIsoElectronsWP80'), srcMET = cms.InputTag('patType1CorrectedPFMet'), verbosity = cms.untracked.int32(0) ) process.tightWenuSelectionSequence += process.WenuCandidates process.selectedWenuCandidates = cms.EDFilter("PATElecNuPairSelector", src = cms.InputTag("WenuCandidates"), cut = cms.string('mt > 50.'), filter = cms.bool(False) ) process.tightWenuSelectionSequence += process.selectedWenuCandidates process.tightWenuFilter = cms.EDFilter("CandViewCountFilter", src = cms.InputTag("selectedWenuCandidates"), minNumber = cms.uint32(1) ) process.tightWenuSelectionSequence += process.tightWenuFilter
[ "sha1-5c72da6f595cce9b6b48aff6d56f01e9beb4aad1@cern.ch" ]
sha1-5c72da6f595cce9b6b48aff6d56f01e9beb4aad1@cern.ch
24929fa4de6e90da6f4465579ec2ec11a4964780
0cf44538d8ae18de4effce86378d44d03c894f53
/NLP100/08.py
ac2635d771c8f8a46e7b875a553491119a40e95a
[]
no_license
ichimunemasa/Study
f8b882de73567d7dd41227779f8ca1dd43372b63
ccd6103483a84c9196e20421d71e96ece770cb72
refs/heads/master
2020-04-15T14:02:26.149991
2016-09-08T03:59:25
2016-09-08T03:59:25
59,583,104
0
0
null
null
null
null
UTF-8
Python
false
false
283
py
#-*- coding: utf-8 -*- def cipher(string): retString = "".join(chr(219-ord(c)) if "a"<=c<="z" else c for c in string) return retString if __name__=="__main__": sentence="Hello, world!" ciphertext=cipher(sentence) print(sentence) print(ciphertext) print(cipher(ciphertext))
[ "isshu.mumanesa@gmail.com" ]
isshu.mumanesa@gmail.com
5e465d0d4e698d15d7f0a5bb851da68800888aa9
c9ddbdb5678ba6e1c5c7e64adf2802ca16df778c
/cases/synthetic/tree-big-5202.py
4837237ad482a640129ddcb32bd111f766a43dd6
[]
no_license
Virtlink/ccbench-chocopy
c3f7f6af6349aff6503196f727ef89f210a1eac8
c7efae43bf32696ee2b2ee781bdfe4f7730dec3f
refs/heads/main
2023-04-07T15:07:12.464038
2022-02-03T15:42:39
2022-02-03T15:42:39
451,969,776
0
0
null
null
null
null
UTF-8
Python
false
false
23,288
py
# Binary-search trees class TreeNode(object): value:int = 0 left:"TreeNode" = None right:"TreeNode" = None def insert(self:"TreeNode", x:int) -> bool: if x < self.value: if self.left is None: self.left = makeNode(x) return True else: return self.left.insert(x) elif x > self.value: if self.right is None: self.right = makeNode(x) return True else: return self.right.insert(x) return False def contains(self:"TreeNode", x:int) -> bool: if x < self.value: if self.left is None: return False else: return self.left.contains(x) elif x > self.value: if self.right is None: return False else: return self.right.contains(x) else: return True class TreeNode2(object): value:int = 0 value2:int = 0 left:"TreeNode2" = None left2:"TreeNode2" = None right:"TreeNode2" = None right2:"TreeNode2" = None def insert(self:"TreeNode2", x:int) -> bool: if x < self.value: if self.left is None: self.left = makeNode2(x, x) return True else: return self.left.insert(x) elif x > self.value: if self.right is None: self.right = makeNode2(x, x) return True else: return self.right.insert(x) return False def insert2(self:"TreeNode2", x:int, x2:int) -> bool: if x < self.value: if self.left is None: self.left = makeNode2(x, x) return True else: return self.left.insert(x) elif x > self.value: if self.right is None: self.right = makeNode2(x, x) return True else: return self.right.insert(x) return False def contains(self:"TreeNode2", x:int) -> bool: if x < self.value: if self.left is None: return False else: return self.left.contains(x) elif x > self.value: if self.right is None: return False else: return self.right.contains(x) else: return True def contains2(self:"TreeNode2", x:int, x2:int) -> bool: if x < self.value: if self.left is None: return False else: return self.left.contains(x) elif x > self.value: if self.right is None: return False else: return self.right.contains(x) else: return True class TreeNode3(object): value:int = 0 value2:int = 0 value3:int = 0 left:"TreeNode3" = None left2:"TreeNode3" = None left3:"TreeNode3" = None right:"TreeNode3" = None right2:"TreeNode3" = None right3:"TreeNode3" = None def insert(self:"TreeNode3", x:int) -> bool: if x < self.value: if self.left is None: self.left = makeNode3(x, x, x) return True else: return self.left.insert(x) elif x > self.value: if self.right is None: self.right = makeNode3(x, x, x) return True else: return self.right.insert(x) return False def insert2(self:"TreeNode3", x:int, x2:int) -> bool: if x < self.value: if self.left is None: self.left = makeNode3(x, x, x) return True else: return self.left.insert(x) elif x > self.value: if self.right is None: self.right = makeNode3(x, x, x) return True else: return self.right.insert(x) return False def insert3(self:"TreeNode3", x:int, x2:int, x3:int) -> bool: if x < self.value: if self.left is None: self.left = makeNode3(x, x, x) return True else: return self.left.insert(x) elif x > self.value: if self.right is None: self.right = makeNode3(x, x, x) return True else: return self.right.insert(x) return False def contains(self:"TreeNode3", x:int) -> bool: if x < self.value: if self.left is None: return False else: return self.left.contains(x) elif x > self.value: if self.right is None: return False else: return self.right.contains(x) else: return True def contains2(self:"TreeNode3", x:int, x2:int) -> bool: if x < self.value: if self.left is None: return False else: return self.left.contains(x) elif x > self.value: if self.right is None: return False else: return self.right.contains(x) else: return True def contains3(self:"TreeNode3", x:int, x2:int, x3:int) -> bool: if x < self.value: if self.left is None: return False else: return self.left.contains(x) elif x > self.value: if self.right is None: return False else: return self.right.contains(x) else: return True class TreeNode4(object): value:int = 0 value2:int = 0 value3:int = 0 value4:int = 0 left:"TreeNode4" = None left2:"TreeNode4" = None left3:"TreeNode4" = None left4:"TreeNode4" = None right:"TreeNode4" = None right2:"TreeNode4" = None right3:"TreeNode4" = None right4:"TreeNode4" = None def insert(self:"TreeNode4", x:int) -> bool: if x < self.value: if self.left is None: self.left = makeNode4(x, x, x, x) return True else: return self.left.insert(x) elif x > self.value: if self.right is None: self.right = makeNode4(x, x, x, x) return True else: return self.right.insert(x) return False def insert2(self:"TreeNode4", x:int, x2:int) -> bool: if x < self.value: if self.left is None: self.left = makeNode4(x, x, x, x) return True else: return self.left.insert(x) elif x > self.value: if self.right is None: self.right = makeNode4(x, x, x, x) return True else: return self.right.insert(x) return False def insert3(self:"TreeNode4", x:int, x2:int, x3:int) -> bool: if x < self.value: if self.left is None: self.left = makeNode4(x, x, x, x) return True else: return self.left.insert(x) elif x > self.value: if self.right is None: self.right = makeNode4(x, x, x, x) return True else: return self.right.insert(x) return False def insert4(self:"TreeNode4", x:int, x2:int, x3:int, x4:int) -> bool: if x < self.value: if self.left is None: self.left = makeNode4(x, x, x, x) return True else: return self.left.insert(x) elif x > self.value: if self.right is None: self.right = makeNode4(x, x, x, x) return True else: return self.right.insert(x) return False def contains(self:"TreeNode4", x:int) -> bool: if x < self.value: if self.left is None: return False else: return self.left.contains(x) elif x > self.value: if self.right is None: return False else: return self.right.contains(x) else: return True def contains2(self:"TreeNode4", x:int, x2:int) -> bool: if x < self.value: if self.left is None: return False else: return self.left.contains(x) elif x > self.value: if self.right is None: return False else: return self.right.contains(x) else: return True def contains3(self:"TreeNode4", x:int, x2:int, x3:int) -> bool: if x < self.value: if self.left is None: return False else: return self.left.contains(x) elif x > self.value: if self.right is None: return False else: return self.right.contains(x) else: return True def contains4(self:"TreeNode4", x:int, x2:int, x3:int, x4:int) -> bool: if x < self.value: if self.left is None: return False else: return self.left.contains(x) elif x > self.value: if self.right is None: return False else: return self.right.contains(x) else: return True class TreeNode5(object): value:int = 0 value2:int = 0 value3:int = 0 value4:int = 0 value5:int = 0 left:"TreeNode5" = None left2:"TreeNode5" = None left3:"TreeNode5" = None left4:"TreeNode5" = None left5:"TreeNode5" = None right:"TreeNode5" = None right2:"TreeNode5" = None right3:"TreeNode5" = None right4:"TreeNode5" = None right5:"TreeNode5" = None def insert(self:"TreeNode5", x:int) -> bool: if x < self.value: if self.left is None: self.left = makeNode5(x, x, x, x, x) return True else: return self.left.insert(x) elif x > self.value: if self.right is None: self.right = makeNode5(x, x, x, x, x) return True else: return self.right.insert(x) return False def insert2(self:"TreeNode5", x:int, x2:int) -> bool: if x < self.value: if self.left is None: self.left = makeNode5(x, x, x, x, x) return True else: return self.left.insert(x) elif x > self.value: if self.right is None: self.right = makeNode5(x, x, x, x, x) return True else: return self.right.insert(x) return False def insert3(self:"TreeNode5", x:int, x2:int, x3:int) -> bool: if x < self.value: if self.left is None: self.left = makeNode5(x, x, x, x, x) return True else: return self.left.insert(x) elif x > self.value: if self.right is None: self.right = makeNode5(x, x, x, x, x) return True else: return self.right.insert(x) return False def insert4(self:"TreeNode5", x:int, x2:int, x3:int, x4:int) -> bool: if x < self.value: if self.left is None: self.left = makeNode5(x, x, x, x, x) return True else: return self.left.insert(x) elif x > self.value: if self.right is None: self.right = makeNode5(x, x, x, x, x) return True else: return self.right.insert(x) return False def insert5(self:"TreeNode5", x:int, x2:int, x3:int, x4:int, x5:int) -> bool: if x < self.value: if self.left is None: self.left = makeNode5(x, x, x, x, x) return True else: return self.left.insert(x) elif x > self.value: if self.right is None: self.right = makeNode5(x, x, x, x, x) return True else: return self.right.insert(x) return False def contains(self:"TreeNode5", x:int) -> bool: if x < self.value: if self.left is None: return False else: return self.left.contains(x) elif x > self.value: if self.right is None: return False else: return self.right.contains(x) else: return True def contains2(self:"TreeNode5", x:int, x2:int) -> bool: if x < self.value: if self.left is None: return False else: return self.left.contains(x) elif x > self.value: if self.right is None: return False else: return self.right.contains(x) else: return True def contains3(self:"TreeNode5", x:int, x2:int, x3:int) -> bool: if x < self.value: if self.left is None: return False else: return self.left.contains(x) elif x > self.value: if self.right is None: return False else: return self.right.contains(x) else: return True def contains4(self:"TreeNode5", x:int, x2:int, x3:int, x4:int) -> bool: if x < self.value: if self.left is None: return False else: return self.left.contains(x) elif x > self.value: if self.right is None: return False else: return self.right.contains(x) else: return True def contains5(self:"TreeNode5", x:int, x2:int, x3:int, x4:int, x5:int) -> bool: if x < self.value: if self.left is None: return False else: return self.left.contains(x) elif x > self.value: if self.right is None: return False else: return self.right.contains(x) else: return True class Tree(object): root:TreeNode = None size:int = 0 def insert(self:"Tree", x:int) -> object: if self.root is None: self.root = makeNode(x) self.size = 1 else: if self.root.insert(x): self.size = self.size + 1 def contains(self:"Tree", x:int) -> bool: if self.root is None: return False else: return self.root.contains(x) class Tree2(object): root:TreeNode2 = None root2:TreeNode2 = None size:int = 0 size2:int = 0 def insert(self:"Tree2", x:int) -> object: if self.root is None: self.root = makeNode2(x, x) self.size = 1 else: if self.root.insert(x): self.size = self.size + 1 def insert2(self:"Tree2", x:int, x2:int) -> object: if self.$ID is None: self.root = makeNode2(x, x) self.size = 1 else: if self.root.insert(x): self.size = self.size + 1 def contains(self:"Tree2", x:int) -> bool: if self.root is None: return False else: return self.root.contains(x) def contains2(self:"Tree2", x:int, x2:int) -> bool: if self.root is None: return False else: return self.root.contains(x) class Tree3(object): root:TreeNode3 = None root2:TreeNode3 = None root3:TreeNode3 = None size:int = 0 size2:int = 0 size3:int = 0 def insert(self:"Tree3", x:int) -> object: if self.root is None: self.root = makeNode3(x, x, x) self.size = 1 else: if self.root.insert(x): self.size = self.size + 1 def insert2(self:"Tree3", x:int, x2:int) -> object: if self.root is None: self.root = makeNode3(x, x, x) self.size = 1 else: if self.root.insert(x): self.size = self.size + 1 def insert3(self:"Tree3", x:int, x2:int, x3:int) -> object: if self.root is None: self.root = makeNode3(x, x, x) self.size = 1 else: if self.root.insert(x): self.size = self.size + 1 def contains(self:"Tree3", x:int) -> bool: if self.root is None: return False else: return self.root.contains(x) def contains2(self:"Tree3", x:int, x2:int) -> bool: if self.root is None: return False else: return self.root.contains(x) def contains3(self:"Tree3", x:int, x2:int, x3:int) -> bool: if self.root is None: return False else: return self.root.contains(x) class Tree4(object): root:TreeNode4 = None root2:TreeNode4 = None root3:TreeNode4 = None root4:TreeNode4 = None size:int = 0 size2:int = 0 size3:int = 0 size4:int = 0 def insert(self:"Tree4", x:int) -> object: if self.root is None: self.root = makeNode4(x, x, x, x) self.size = 1 else: if self.root.insert(x): self.size = self.size + 1 def insert2(self:"Tree4", x:int, x2:int) -> object: if self.root is None: self.root = makeNode4(x, x, x, x) self.size = 1 else: if self.root.insert(x): self.size = self.size + 1 def insert3(self:"Tree4", x:int, x2:int, x3:int) -> object: if self.root is None: self.root = makeNode4(x, x, x, x) self.size = 1 else: if self.root.insert(x): self.size = self.size + 1 def insert4(self:"Tree4", x:int, x2:int, x3:int, x4:int) -> object: if self.root is None: self.root = makeNode4(x, x, x, x) self.size = 1 else: if self.root.insert(x): self.size = self.size + 1 def contains(self:"Tree4", x:int) -> bool: if self.root is None: return False else: return self.root.contains(x) def contains2(self:"Tree4", x:int, x2:int) -> bool: if self.root is None: return False else: return self.root.contains(x) def contains3(self:"Tree4", x:int, x2:int, x3:int) -> bool: if self.root is None: return False else: return self.root.contains(x) def contains4(self:"Tree4", x:int, x2:int, x3:int, x4:int) -> bool: if self.root is None: return False else: return self.root.contains(x) class Tree5(object): root:TreeNode5 = None root2:TreeNode5 = None root3:TreeNode5 = None root4:TreeNode5 = None root5:TreeNode5 = None size:int = 0 size2:int = 0 size3:int = 0 size4:int = 0 size5:int = 0 def insert(self:"Tree5", x:int) -> object: if self.root is None: self.root = makeNode5(x, x, x, x, x) self.size = 1 else: if self.root.insert(x): self.size = self.size + 1 def insert2(self:"Tree5", x:int, x2:int) -> object: if self.root is None: self.root = makeNode5(x, x, x, x, x) self.size = 1 else: if self.root.insert(x): self.size = self.size + 1 def insert3(self:"Tree5", x:int, x2:int, x3:int) -> object: if self.root is None: self.root = makeNode5(x, x, x, x, x) self.size = 1 else: if self.root.insert(x): self.size = self.size + 1 def insert4(self:"Tree5", x:int, x2:int, x3:int, x4:int) -> object: if self.root is None: self.root = makeNode5(x, x, x, x, x) self.size = 1 else: if self.root.insert(x): self.size = self.size + 1 def insert5(self:"Tree5", x:int, x2:int, x3:int, x4:int, x5:int) -> object: if self.root is None: self.root = makeNode5(x, x, x, x, x) self.size = 1 else: if self.root.insert(x): self.size = self.size + 1 def contains(self:"Tree5", x:int) -> bool: if self.root is None: return False else: return self.root.contains(x) def contains2(self:"Tree5", x:int, x2:int) -> bool: if self.root is None: return False else: return self.root.contains(x) def contains3(self:"Tree5", x:int, x2:int, x3:int) -> bool: if self.root is None: return False else: return self.root.contains(x) def contains4(self:"Tree5", x:int, x2:int, x3:int, x4:int) -> bool: if self.root is None: return False else: return self.root.contains(x) def contains5(self:"Tree5", x:int, x2:int, x3:int, x4:int, x5:int) -> bool: if self.root is None: return False else: return self.root.contains(x) def makeNode(x: int) -> TreeNode: b:TreeNode = None b = TreeNode() b.value = x return b def makeNode2(x: int, x2: int) -> TreeNode2: b:TreeNode2 = None b2:TreeNode2 = None b = TreeNode2() b.value = x return b def makeNode3(x: int, x2: int, x3: int) -> TreeNode3: b:TreeNode3 = None b2:TreeNode3 = None b3:TreeNode3 = None b = TreeNode3() b.value = x return b def makeNode4(x: int, x2: int, x3: int, x4: int) -> TreeNode4: b:TreeNode4 = None b2:TreeNode4 = None b3:TreeNode4 = None b4:TreeNode4 = None b = TreeNode4() b.value = x return b def makeNode5(x: int, x2: int, x3: int, x4: int, x5: int) -> TreeNode5: b:TreeNode5 = None b2:TreeNode5 = None b3:TreeNode5 = None b4:TreeNode5 = None b5:TreeNode5 = None b = TreeNode5() b.value = x return b # Input parameters n:int = 100 n2:int = 100 n3:int = 100 n4:int = 100 n5:int = 100 c:int = 4 c2:int = 4 c3:int = 4 c4:int = 4 c5:int = 4 # Data t:Tree = None t2:Tree = None t3:Tree = None t4:Tree = None t5:Tree = None i:int = 0 i2:int = 0 i3:int = 0 i4:int = 0 i5:int = 0 k:int = 37813 k2:int = 37813 k3:int = 37813 k4:int = 37813 k5:int = 37813 # Crunch t = Tree() while i < n: t.insert(k) k = (k * 37813) % 37831 if i % c != 0: t.insert(i) i = i + 1 print(t.size) for i in [4, 8, 15, 16, 23, 42]: if t.contains(i): print(i)
[ "647530+Virtlink@users.noreply.github.com" ]
647530+Virtlink@users.noreply.github.com
10e22fdfd1f29330b01da0a09e6fed784e1be70d
6009d030d328cd081df8a2b7262e5138ffdc51ee
/waifu2x/waifu2x-caffe@lltcggie/upconv_7_photo/symbol.py
3b610e91707b0f4d1a539405d3a69d691ec4e037
[]
no_license
DBSOM-X/Super-Resolution-Zoo
dcaa7f63c987e24691100fe833b6f480142bea48
041842f177ab4aa59287f8561ec9b3446bd4826c
refs/heads/master
2022-06-14T05:51:24.716028
2019-06-25T02:00:15
2019-06-25T02:00:15
null
0
0
null
null
null
null
UTF-8
Python
false
false
2,187
py
import mxnet as mx data = mx.symbol.Variable(name='data') data = mx.sym.pad(data=data, mode='reflect', pad_width=(0, 0, 0, 0, 7, 7, 7, 7)) conv1_layer = mx.symbol.Convolution(name='conv1_layer', data=data, num_filter=16, pad=(0, 0), kernel=(3,3), stride=(1,1), no_bias=False, dilate=(1, 1), num_group=1, layout='NCHW') conv1_relu_layer = mx.symbol.LeakyReLU(name='conv1_relu_layer', data=conv1_layer, act_type='leaky', slope=0.100000) conv2_layer = mx.symbol.Convolution(name='conv2_layer', data=conv1_relu_layer, num_filter=32, pad=(0, 0), kernel=(3,3), stride=(1,1), no_bias=False, dilate=(1, 1), num_group=1, layout='NCHW') conv2_relu_layer = mx.symbol.LeakyReLU(name='conv2_relu_layer', data=conv2_layer, act_type='leaky', slope=0.100000) conv3_layer = mx.symbol.Convolution(name='conv3_layer', data=conv2_relu_layer, num_filter=64, pad=(0, 0), kernel=(3,3), stride=(1,1), no_bias=False, dilate=(1, 1), num_group=1, layout='NCHW') conv3_relu_layer = mx.symbol.LeakyReLU(name='conv3_relu_layer', data=conv3_layer, act_type='leaky', slope=0.100000) conv4_layer = mx.symbol.Convolution(name='conv4_layer', data=conv3_relu_layer, num_filter=128, pad=(0, 0), kernel=(3,3), stride=(1,1), no_bias=False, dilate=(1, 1), num_group=1, layout='NCHW') conv4_relu_layer = mx.symbol.LeakyReLU(name='conv4_relu_layer', data=conv4_layer, act_type='leaky', slope=0.100000) conv5_layer = mx.symbol.Convolution(name='conv5_layer', data=conv4_relu_layer, num_filter=128, pad=(0, 0), kernel=(3,3), stride=(1,1), no_bias=False, dilate=(1, 1), num_group=1, layout='NCHW') conv5_relu_layer = mx.symbol.LeakyReLU(name='conv5_relu_layer', data=conv5_layer, act_type='leaky', slope=0.100000) conv6_layer = mx.symbol.Convolution(name='conv6_layer', data=conv5_relu_layer, num_filter=256, pad=(0, 0), kernel=(3,3), stride=(1,1), no_bias=False, dilate=(1, 1), num_group=1, layout='NCHW') conv6_relu_layer = mx.symbol.LeakyReLU(name='conv6_relu_layer', data=conv6_layer, act_type='leaky', slope=0.100000) conv7_layer = mx.symbol.Deconvolution(name='conv7_layer', data=conv6_relu_layer, num_filter=3, pad=(3, 3), kernel=(4,4), stride=(2,2), no_bias=False, dilate=(1, 1), num_group=1, layout='NCHW')
[ "WolframRhodium@users.noreply.github.com" ]
WolframRhodium@users.noreply.github.com
5a793b97cdddcd7a408414d3a47b2683e16bea00
dacae380d3c52ae08e666195ead9366b3a7240fc
/task1/code/problem1.py
45cdc3257b5ab3c22fe05f722861a3ec9bac27a8
[]
no_license
wangyu33/UCAS-image-processing-course
a879a50907fdae27f66bd28db5be25144951f075
a6a8ee17d4e1879c81059c1a56649e6387a9aa89
refs/heads/master
2020-12-08T13:32:06.855286
2020-01-10T15:54:04
2020-01-10T15:54:04
232,992,838
1
0
null
null
null
null
UTF-8
Python
false
false
1,111
py
import os import cv2 import matplotlib.pyplot as plt import numpy as np def scanLine4e(f, I, loc): #f:gray level image #I -> int loc -> str if loc == 'row': return f[I,:] if loc == 'column': return f[:,I] return '参数错误' def run(filename): f = cv2.imread(filename, cv2.IMREAD_GRAYSCALE) r = np.size(f,0) c = np.size(f,1) plt.figure(filename) plt.imshow(f, cmap = 'gray') plt.show() f_r = r//2 #求中心行的index,当行数为偶数时取较大中心行 f_c = c//2 #求中心列的index,当列数为偶数时取较大中心列 r_vector = scanLine4e(f,f_r,'row') c_vector = scanLine4e(f,f_c,'column') xr = np.linspace(1,r,r) xc = np.linspace(1,c,c) plt.figure() plt.plot(xc, r_vector, 'bo--', ms = 2, label = 'row pixel') plt.plot(xr, c_vector, 'ro--', ms = 2, label='column pixel') plt.legend(loc = 1) plt.ylabel('pixel value') plt.title(filename) plt.show() def main(): run('cameraman.tif') run('einstein.tif') if __name__ == '__main__': main()
[ "1134711093@qq.com" ]
1134711093@qq.com
6150575801b07567ca45d414251a7e4ff526a176
6a63b4a189ba65822971ba08b018bf4e6123759a
/hunkim-lecture/rnn.py
0927dab8238731afe9d5b220b45a5a943765da8f
[]
no_license
HyundongHwang/MyMlStudy
f2d941cd8d38417fd8fcae020d7f21a613d4cb3f
5459639f61c3ab8004900efcd1204a90dd91376f
refs/heads/master
2021-01-12T02:11:37.087188
2018-04-19T13:42:02
2018-04-19T13:42:02
78,484,938
0
0
null
null
null
null
UTF-8
Python
false
false
93
py
import tensorflow as tf from tensorflow.models.rnn import rnn, rnn_cell import numpy as numpy
[ "hhd2002@gmail.com" ]
hhd2002@gmail.com
11fd12954e27d2a0cf6c67fed24d94c229077b0d
867fe9e56d801d14af1cf13077e246b80cede6a7
/stoys/spark/dp/dp_result.py
264c4fa45d19bc7297ef4f24a06befa2ee3e9deb
[ "Apache-2.0" ]
permissive
stoys-io/stoys-python
f3bb0925f875d95909f9944b7438c8d27112653d
c2095ff74152690b1d8ea799c5bc8910a71921fb
refs/heads/main
2023-08-31T01:17:05.312755
2021-10-27T09:27:33
2021-10-27T09:27:33
420,110,606
1
0
null
null
null
null
UTF-8
Python
false
false
1,238
py
from typing import Dict, List, Optional from ...utils.case_class import CaseClassMirror, case_class_mirror @case_class_mirror("io.stoys.spark.dp.DpPmfBucket") class DpPmfBucket(CaseClassMirror): low: float high: float count: int @case_class_mirror("io.stoys.spark.dp.DpItem") class DpItem(CaseClassMirror): item: str count: int @case_class_mirror("io.stoys.spark.dp.DpColumn") class DpColumn(CaseClassMirror): name: str data_type: str data_type_json: str nullable: bool enum_values: List[str] format: Optional[str] count: int count_empty: Optional[int] count_nulls: Optional[int] count_unique: Optional[int] count_zeros: Optional[int] max_length: Optional[int] min: Optional[str] max: Optional[str] mean: Optional[float] pmf: List[DpPmfBucket] items: List[DpItem] extras: Dict[str, str] @case_class_mirror("io.stoys.spark.dp.DpTable") class DpTable(CaseClassMirror): rows: int @case_class_mirror("io.stoys.spark.dp.DpResult") class DpResult(CaseClassMirror): table: DpTable columns: List[DpColumn] def _repr_html_(self) -> str: from ...ui.dp_ui import dp_result_to_html return dp_result_to_html(self)
[ "jendap@gmail.com" ]
jendap@gmail.com
f253bf0380287d0b75e4c949fe2cf669e820ae24
94c7bcc7fa0749ef3890af6dac39341c14f5d259
/tensorflow/python/eager/tensor_test.py
b044b30231603b0265aa1ef0320e9f1cfb303724
[ "Apache-2.0" ]
permissive
lgeiger/tensorflow
e75e32cd23a45d29bac1fc10eda23499a66d188a
1bf9ec7f8545c7aa6fa915c6576a3b984af59ded
refs/heads/master
2023-08-18T23:16:38.380820
2018-04-26T20:47:51
2018-04-26T20:47:51
127,307,734
2
1
Apache-2.0
2018-03-29T15:02:37
2018-03-29T15:02:36
null
UTF-8
Python
false
false
12,165
py
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Unit tests for TensorFlow "Eager" Mode's Tensor class.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import copy import re import numpy as np from tensorflow.python import pywrap_tensorflow from tensorflow.python.eager import context from tensorflow.python.eager import core from tensorflow.python.eager import test from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.framework import test_util def _create_tensor(value, device=None, dtype=None): ctx = context.context() if device is None: device = ctx.device_name if dtype is not None: dtype = dtype.as_datatype_enum try: return ops.EagerTensor( value, context=ctx._handle, device=device, dtype=dtype) except core._NotOkStatusException as e: # pylint: disable=protected-access raise core._status_to_exception(e.code, e.message) class TFETensorTest(test_util.TensorFlowTestCase): def testScalarTensor(self): t = _create_tensor(3, dtype=dtypes.int32) self.assertAllEqual(t, _create_tensor(np.array(3))) self.assertEqual(dtypes.int32, t.dtype) self.assertEqual(0, t.shape.ndims) self.assertAllEqual([], t.shape.as_list()) self.assertIn("tf.Tensor", str(t)) self.assertIn("tf.Tensor", repr(t)) def testBadConstructorArgs(self): ctx = context.context() handle = ctx._handle device = ctx.device_name # Missing context. with self.assertRaisesRegexp( TypeError, r"Required argument 'context' \(pos 2\) not found"): ops.EagerTensor(1, device=device) # Missing device. with self.assertRaisesRegexp( TypeError, r"Required argument 'device' \(pos 3\) not found"): ops.EagerTensor(1, context=handle) # Bad dtype type. with self.assertRaisesRegexp(TypeError, "Expecting a DataType value for dtype. Got"): ops.EagerTensor(1, context=handle, device=device, dtype="1") # Following errors happen when trying to copy to GPU. if not context.context().num_gpus(): self.skipTest("No GPUs found") with ops.device("/device:GPU:0"): device = ctx.device_name # Bad context. with self.assertRaisesRegexp( TypeError, "Expecting a PyCapsule encoded context handle. Got"): ops.EagerTensor(1.0, context=1, device=device) # Bad device. with self.assertRaisesRegexp( TypeError, "Error parsing device argument to CopyToDevice"): ops.EagerTensor(1.0, context=handle, device=1) def testNumpyValue(self): values = np.array([3.0]) t = _create_tensor(values) self.assertAllEqual(values, t) def testNumpyValueWithCast(self): values = np.array([3.0], dtype=np.float32) t = _create_tensor(values, dtype=dtypes.float64) self.assertAllEqual(values, t) ctx = context.context() # Bad dtype value. with self.assertRaisesRegexp(TypeError, "Invalid dtype argument value"): ops.EagerTensor( values, context=ctx._handle, device=ctx.device_name, dtype=12345) def testNumpyOrderHandling(self): n = np.array([[1, 2], [3, 4]], order="F") t = _create_tensor(n) self.assertAllEqual([[1, 2], [3, 4]], t) def testNumpyArrayDtype(self): tensor = constant_op.constant([1.0, 2.0, 3.0]) numpy_tensor = np.asarray(tensor, dtype=np.int32) self.assertAllEqual(numpy_tensor, [1, 2, 3]) def testNdimsAgreesWithNumpy(self): numpy_tensor = np.asarray(1.0) tensor = constant_op.constant(numpy_tensor) self.assertAllEqual(numpy_tensor.ndim, tensor.ndim) numpy_tensor = np.asarray([1.0, 2.0, 3.0]) tensor = constant_op.constant(numpy_tensor) self.assertAllEqual(numpy_tensor.ndim, tensor.ndim) numpy_tensor = np.asarray([[1.0, 2.0, 3.0], [1.0, 2.0, 3.0]]) tensor = constant_op.constant(numpy_tensor) self.assertAllEqual(numpy_tensor.ndim, tensor.ndim) def testCopy(self): t = constant_op.constant(1.0) tt = copy.copy(t) self.assertAllEqual(tt, 1.0) del tt tt = copy.deepcopy(t) self.assertAllEqual(tt, 1.0) del tt self.assertAllEqual(t, 1.0) def testConstantDtype(self): self.assertEqual(constant_op.constant(1.0, dtype=np.int64).dtype, dtypes.int64) def testTensorAndNumpyMatrix(self): expected = np.array([[1.0, 2.0], [3.0, 4.0]], np.float32) actual = _create_tensor([[1.0, 2.0], [3.0, 4.0]]) self.assertAllEqual(expected, actual) self.assertEqual(np.float32, actual.dtype) self.assertEqual(dtypes.float32, actual.dtype) self.assertAllEqual([2, 2], actual.shape.as_list()) def testFloatDowncast(self): # Unless explicitly specified, float64->float32 t = _create_tensor(3.0) self.assertEqual(dtypes.float32, t.dtype) t = _create_tensor(3.0, dtype=dtypes.float64) self.assertEqual(dtypes.float64, t.dtype) def testBool(self): t = _create_tensor(False) if t: self.assertFalse(True) def testIntDowncast(self): t = _create_tensor(3) self.assertEqual(dtypes.int32, t.dtype) t = _create_tensor(3, dtype=dtypes.int64) self.assertEqual(dtypes.int64, t.dtype) t = _create_tensor(2**33) self.assertEqual(dtypes.int64, t.dtype) def testTensorCreationFailure(self): with self.assertRaises(ValueError): # Should fail because the each row of the Python object has a different # number of columns. self.assertEqual(None, _create_tensor([[1], [1, 2]])) def testMultiLineTensorStr(self): t = _create_tensor(np.eye(3)) tensor_str = str(t) self.assertIn("shape=%s, dtype=%s" % (t.shape, t.dtype.name), tensor_str) self.assertIn(str(t), tensor_str) def testMultiLineTensorRepr(self): t = _create_tensor(np.eye(3)) tensor_repr = repr(t) self.assertTrue(tensor_repr.startswith("<")) self.assertTrue(tensor_repr.endswith(">")) self.assertIn("id=%d, shape=%s, dtype=%s, numpy=\n%r" % (t._id, t.shape, t.dtype.name, t.numpy()), tensor_repr) def testTensorStrReprObeyNumpyPrintOptions(self): orig_threshold = np.get_printoptions()["threshold"] orig_edgeitems = np.get_printoptions()["edgeitems"] np.set_printoptions(threshold=2, edgeitems=1) t = _create_tensor(np.arange(10, dtype=np.int32)) self.assertTrue(re.match(r".*\[.*0.*\.\.\..*9.*\]", str(t))) self.assertTrue(re.match(r".*\[.*0.*\.\.\..*9.*\]", repr(t))) # Clean up: reset to previous printoptions. np.set_printoptions(threshold=orig_threshold, edgeitems=orig_edgeitems) def testZeroDimTensorStr(self): t = _create_tensor(42) self.assertIn("42, shape=(), dtype=int32", str(t)) def testZeroDimTensorRepr(self): t = _create_tensor(42) self.assertTrue(repr(t).startswith("<")) self.assertTrue(repr(t).endswith(">")) self.assertIn("id=%d, shape=(), dtype=int32, numpy=42" % t._id, repr(t)) def testZeroSizeTensorStr(self): t = _create_tensor(np.zeros(0, dtype=np.float32)) self.assertIn("[], shape=(0,), dtype=float32", str(t)) def testZeroSizeTensorRepr(self): t = _create_tensor(np.zeros(0, dtype=np.float32)) self.assertTrue(repr(t).startswith("<")) self.assertTrue(repr(t).endswith(">")) self.assertIn("id=%d, shape=(0,), dtype=float32, numpy=%r" % (t._id, t.numpy()), repr(t)) def testStringTensor(self): t_np_orig = np.array([[b"a", b"ab"], [b"abc", b"abcd"]]) t = _create_tensor(t_np_orig) t_np = t.numpy() self.assertTrue(np.all(t_np == t_np_orig), "%s vs %s" % (t_np, t_np_orig)) def testIterateOverTensor(self): l = [[1, 2], [3, 4]] t = _create_tensor(l) for list_element, tensor_element in zip(l, t): self.assertAllEqual(list_element, tensor_element.numpy()) def testStringTensorOnGPU(self): if not context.context().num_gpus(): self.skipTest("No GPUs found") with ops.device("/device:GPU:0"): with self.assertRaisesRegexp( RuntimeError, "Can't copy Tensor with type string to device"): _create_tensor("test string") class TFETensorUtilTest(test_util.TensorFlowTestCase): def testListOfThree(self): t1 = _create_tensor([[1, 2], [3, 4], [5, 6]], dtype=dtypes.int32) t2 = _create_tensor([[1, 2, 5], [3, 4, 5]], dtype=dtypes.int32) t3 = _create_tensor([[1], [3], [5], [6]], dtype=dtypes.int32) r = pywrap_tensorflow.TFE_Py_TensorShapeSlice([t1, t2, t3], 0) self.assertAllEqual(np.array([3, 2, 4]), r.numpy()) r = pywrap_tensorflow.TFE_Py_TensorShapeSlice([t1, t2, t3], 1) self.assertAllEqual(np.array([2, 3, 1]), r.numpy()) def testEmptyTensorList(self): a = pywrap_tensorflow.TFE_Py_TensorShapeSlice([], 0) self.assertTrue(isinstance(a, ops.EagerTensor)) self.assertEqual(0, a.numpy().size) def testTensorListContainsNonTensors(self): t1 = _create_tensor([1, 2], dtype=dtypes.int32) with self.assertRaisesRegexp( TypeError, r"Expected a list of EagerTensors but element 1 has type \"str\""): pywrap_tensorflow.TFE_Py_TensorShapeSlice([t1, "abc"], 0) with self.assertRaisesRegexp( TypeError, r"Expected a list of EagerTensors but element 0 has type \"int\""): pywrap_tensorflow.TFE_Py_TensorShapeSlice([2, t1], 0) def testTensorListNotList(self): t1 = _create_tensor([1, 2], dtype=dtypes.int32) with self.assertRaisesRegexp( TypeError, r"tensors argument must be a list or a tuple. Got \"EagerTensor\""): pywrap_tensorflow.TFE_Py_TensorShapeSlice(t1, -2) def testNegativeSliceDim(self): t1 = _create_tensor([1, 2], dtype=dtypes.int32) with self.assertRaisesRegexp( ValueError, r"Slice dimension must be non-negative. Got -2"): pywrap_tensorflow.TFE_Py_TensorShapeSlice([t1], -2) def testUnicode(self): self.assertEqual(constant_op.constant(u"asdf").numpy(), b"asdf") def testSliceDimOutOfRange(self): t1 = _create_tensor([[1, 2], [3, 4], [5, 6]], dtype=dtypes.int32) t2 = _create_tensor([1, 2], dtype=dtypes.int32) t3 = _create_tensor(2, dtype=dtypes.int32) with self.assertRaisesRegexp( IndexError, r"Slice dimension \(2\) must be smaller than rank of all tensors, " "but tensor at index 0 has rank 2"): pywrap_tensorflow.TFE_Py_TensorShapeSlice([t1], 2) with self.assertRaisesRegexp( IndexError, r"Slice dimension \(1\) must be smaller than rank of all tensors, " "but tensor at index 0 has rank 1"): pywrap_tensorflow.TFE_Py_TensorShapeSlice([t2], 1) with self.assertRaisesRegexp( IndexError, r"Slice dimension \(1\) must be smaller than rank of all tensors, " "but tensor at index 1 has rank 1"): pywrap_tensorflow.TFE_Py_TensorShapeSlice([t1, t2], 1) with self.assertRaisesRegexp( IndexError, r"Slice dimension \(0\) must be smaller than rank of all tensors, " "but tensor at index 0 has rank 0"): pywrap_tensorflow.TFE_Py_TensorShapeSlice([t3], 0) with self.assertRaisesRegexp( IndexError, r"Slice dimension \(0\) must be smaller than rank of all tensors, " "but tensor at index 2 has rank 0"): pywrap_tensorflow.TFE_Py_TensorShapeSlice([t2, t1, t3], 0) if __name__ == "__main__": test.main()
[ "gardener@tensorflow.org" ]
gardener@tensorflow.org
f1ff22df803d0c4e27d17a93539483aaf02c1abd
60cd30b5c72ec7f6ce3b2d2f6582382c296d64f5
/src/docker/captum_xil/captum/attr/_utils/batching.py
95f73d00573182acb849f43cb4b98094a2cb1537
[ "BSD-3-Clause", "MIT" ]
permissive
ml-research/NeSyXIL
5d4ed971f471f73191c1074928524ffd19521630
8a8b2a5e2c8ce57ec73d68ca76d4d95a65530cdd
refs/heads/main
2023-05-31T03:02:34.421669
2021-06-22T09:14:35
2021-06-22T09:14:35
344,822,398
27
1
null
null
null
null
UTF-8
Python
false
false
6,156
py
#!/usr/bin/env python3 import typing from typing import Any, Callable, Dict, Iterator, List, Tuple, Union import torch from torch import Tensor, device from .common import _format_additional_forward_args, _format_input from .typing import ( TargetType, TensorOrTupleOfTensorsGeneric, TupleOrTensorOrBoolGeneric, ) @typing.overload def _tuple_splice_range(inputs: None, start: int, end: int) -> None: ... @typing.overload def _tuple_splice_range(inputs: Tuple, start: int, end: int) -> Tuple: ... def _tuple_splice_range( inputs: Union[None, Tuple], start: int, end: int ) -> Union[None, Tuple]: """ Splices each tensor element of given tuple (inputs) from range start (inclusive) to end (non-inclusive) on its first dimension. If element is not a Tensor, it is left unchanged. It is assumed that all tensor elements have the same first dimension (corresponding to number of examples). The returned value is a tuple with the same length as inputs, with Tensors spliced appropriately. """ assert start < end, "Start point must precede end point for batch splicing." if inputs is None: return None return tuple( inp[start:end] if isinstance(inp, torch.Tensor) else inp for inp in inputs ) def _reduce_list( val_list: List[TupleOrTensorOrBoolGeneric], red_func: Callable[[List], Any] = torch.cat, ) -> TupleOrTensorOrBoolGeneric: """ Applies reduction function to given list. If each element in the list is a Tensor, applies reduction function to all elements of the list, and returns the output Tensor / value. If each element is a boolean, apply any method (or). If each element is a tuple, applies reduction function to corresponding elements of each tuple in the list, and returns tuple of reduction function outputs with length matching the length of tuple val_list[0]. It is assumed that all tuples in the list have the same length and red_func can be applied to all elements in each corresponding position. """ if isinstance(val_list[0], torch.Tensor): return red_func(val_list) elif isinstance(val_list[0], bool): return any(val_list) elif isinstance(val_list[0], tuple): final_out = [] for i in range(len(val_list[0])): final_out.append( _reduce_list([val_elem[i] for val_elem in val_list], red_func) ) else: raise AssertionError( "Elements to be reduced can only be" "either Tensors or tuples containing Tensors." ) return tuple(final_out) def _sort_key_list( keys: List[device], device_ids: Union[None, List[int]] = None ) -> List[device]: """ Sorts list of torch devices (keys) by given index list, device_ids. If keys contains only one device, then the list is returned unchanged. If keys contains a device for which the id is not contained in device_ids, then an error is returned. This method is used to identify the order of DataParallel batched devices, given the device ID ordering. """ if len(keys) == 1: return keys id_dict: Dict[int, device] = {} assert device_ids is not None, "Device IDs must be provided with multiple devices." for key in keys: if key.index in id_dict: raise AssertionError("Duplicate CUDA Device ID identified in device list.") id_dict[key.index] = key out_list = [ id_dict[device_id] for device_id in filter(lambda device_id: device_id in id_dict, device_ids) ] assert len(out_list) == len(keys), "Given Device ID List does not match" "devices with computed tensors." return out_list def _batched_generator( inputs: TensorOrTupleOfTensorsGeneric, additional_forward_args: Any = None, target_ind: TargetType = None, internal_batch_size: Union[None, int] = None, ) -> Iterator[Tuple[Tuple[Tensor, ...], Any, TargetType]]: """ Returns a generator which returns corresponding chunks of size internal_batch_size for both inputs and additional_forward_args. If batch size is None, generator only includes original inputs and additional args. """ assert internal_batch_size is None or ( isinstance(internal_batch_size, int) and internal_batch_size > 0 ), "Batch size must be greater than 0." inputs = _format_input(inputs) additional_forward_args = _format_additional_forward_args(additional_forward_args) num_examples = inputs[0].shape[0] if internal_batch_size is None: yield inputs, additional_forward_args, target_ind else: for current_total in range(0, num_examples, internal_batch_size): yield _tuple_splice_range( inputs, current_total, current_total + internal_batch_size ), _tuple_splice_range( additional_forward_args, current_total, current_total + internal_batch_size, ), target_ind[ current_total : current_total + internal_batch_size ] if isinstance( target_ind, list ) or ( isinstance(target_ind, torch.Tensor) and target_ind.numel() > 1 ) else target_ind def _batched_operator( operator: Callable[..., TupleOrTensorOrBoolGeneric], inputs: TensorOrTupleOfTensorsGeneric, additional_forward_args: Any = None, target_ind: TargetType = None, internal_batch_size: Union[None, int] = None, **kwargs: Any ) -> TupleOrTensorOrBoolGeneric: """ Batches the operation of the given operator, applying the given batch size to inputs and additional forward arguments, and returning the concatenation of the results of each batch. """ all_outputs = [ operator( inputs=input, additional_forward_args=additional, target_ind=target, **kwargs ) for input, additional, target in _batched_generator( inputs, additional_forward_args, target_ind, internal_batch_size ) ] return _reduce_list(all_outputs)
[ "wolf.stammer@gmail.com" ]
wolf.stammer@gmail.com
d45ad25902bd3e9e3fa1fee12604c394fd94e1bb
9fc117f03eb6b31754c977569d8cb734ce7e0838
/game_app_test.py
0523a3d0b2d7027e2604ad3b5bb8c0e145cbd6d7
[]
no_license
Kristina970/number_game
dd39fad033fdc60ab4a8c01623a909beb02cd93e
affc406ed17094adc9a8981b7f243d59ddbc529f
refs/heads/master
2023-02-07T13:22:07.181855
2019-07-26T19:02:11
2019-07-26T19:02:11
196,609,961
0
2
null
2023-02-02T06:37:27
2019-07-12T16:18:06
Python
UTF-8
Python
false
false
269
py
import unittest from app import app class TestHealthEndpoint(unittest.TestCase): def setUp(self): self.app = app.test_client() def test_main_page(self): response = self.app.get('/_health') self.assertEqual(response.status_code, 200)
[ "khrystyna.mashchakevych@gmail.com" ]
khrystyna.mashchakevych@gmail.com
ffcc17620f863bc72cd9ed5d01959bd7b8f7b8b0
27a85a93fe67c8712dba8f2dc936d3f473daee0f
/Week 4/Problem_D.py
93b78b547b32ee8a82fd6a21a39aa86a01aadb67
[]
no_license
thiaguin/Algorithms
472f6653631118ca333dd8a5703fece96d203038
ac51428ae2e6b09e8a205abc69d760846c0e7a39
refs/heads/master
2023-01-23T00:01:42.196935
2020-12-05T03:27:45
2020-12-05T03:27:45
292,856,685
0
0
null
null
null
null
UTF-8
Python
false
false
467
py
# Title -> Heidi Learns Hashing (Easy) # Description -> codeforces.com/problemset/problem/1184/A1 import math n = input() def getResult(n): sqrt = int(math.ceil(math.sqrt(n))) for i in range(1, sqrt): dividend = n - (i * i) - i - 1 divider = 2 * i result = float(dividend) / float(divider) if (result.is_integer() and result > 0): return str(i) + ' ' + str(int(result)) return 'NO' print(getResult(n))
[ "jose.thiago.silva@ccc.ufcg.edu.br" ]
jose.thiago.silva@ccc.ufcg.edu.br
8ff67afb0b28cd776740c8eae4137cf860e8d599
498f2cdfd279c13028835b7dcc7d1d4e3b854f4d
/0x0B-python-input_output/9-add_item.py
459790e8bedd0a07b832a72db522a48d41f01954
[]
no_license
Cristiand187/holbertonschool-higher_level_programming
bf29d3a9bc6617fe4b51e5fc70c8f4dfc2054da5
0e70aaffd89bd0ef353487be227a62b0a8006cea
refs/heads/master
2022-12-25T11:03:42.877379
2020-09-25T04:00:28
2020-09-25T04:00:28
259,311,171
0
0
null
null
null
null
UTF-8
Python
false
false
643
py
#!/usr/bin/python3 """Module""" from sys import argv from pathlib import Path save_to_json_file = __import__('7-save_to_json_file').save_to_json_file load_from_json_file = __import__('8-load_from_json_file').load_from_json_file def add_item(argument): """[summary] Arguments: argument {[type]} -- [description] """ filename = 'add_item.json' if Path(filename).is_file(): my_list = load_from_json_file(filename) else: my_list = [] for elem in range(1, len(argv)): my_list.append(argv[elem]) save_to_json_file(my_list, filename) if __name__ == "__main__": add_item(argv)
[ "cristiand187@hotmail.com" ]
cristiand187@hotmail.com
31ddd336e912065ab635606a27461410d2e59bfa
2562d3a102af3a7e590b28b0d388aaf980edcd97
/Leetcode/SameTree.py
faf271b08993845978463e91a798b5df5c8201ce
[]
no_license
svidyart/PracticeCode
16bc3565d4b0cfc383aad144b6fe70310b55840d
8b03977d606fa4c82039003a3e3e1affd83fb75e
refs/heads/master
2021-01-19T06:46:45.673755
2016-08-09T17:46:48
2016-08-09T17:46:48
65,315,509
0
0
null
null
null
null
UTF-8
Python
false
false
1,061
py
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def isSameTree(self, p, q): """ :type p: TreeNode :type q: TreeNode :rtype: bool """ if(p is None and q is None): return True elif(p is None or q is None): return False if(p.val == q.val): if(p.left is not None and q.left is not None): temp = self.isSameTree(p.left, q.left) if(temp is False): return temp elif(p.left is not None or q.left is not None): return False if(p.right is not None and q.right is not None): return self.isSameTree(p.right, q.right) elif(p.right is not None or q.right is not None): return False else: return True else: return False
[ "shreyasvidyarthi@gmail.com" ]
shreyasvidyarthi@gmail.com
dff8cc56d809d8c84abb02cc259038f50b9df3a3
0b09998b42dfb3d0e076a6c46b2d754f646e6123
/App/UI/UserType.py
1012dcec5ffa4ecdb6326700dbfe83e08a807d5b
[]
no_license
BackendBoys-ISS/issrepo
6b75a1de7aadb9aa891c17cabd4072237ebdd98a
2c92ada314666896e278a4ef49d7be73d205ce21
refs/heads/master
2021-03-26T16:21:06.080950
2020-06-02T22:04:10
2020-06-02T22:04:10
247,722,093
0
0
null
2020-05-05T16:14:30
2020-03-16T14:22:29
Python
UTF-8
Python
false
false
256
py
class UserType: def __init__(self, isOnlyAuthor: bool, isSpeaker: bool, isListener: bool, username: str): self.isOnlyAuthor = isOnlyAuthor self.isSpeaker = isSpeaker self.isListener = isListener self.username = username
[ "balinthandrei@gmail.com" ]
balinthandrei@gmail.com
87ff388116d605759736aa8c0f0378c093a73c0d
e6f9db4cf4913a19f243327329b31485de8da8fe
/GUI/clientRecvCommPage.py
4a8974b3539cbf234200e3b2d09b3c895ec73179
[]
no_license
KareemElozeiri/pythonReverseShell
9c55fbc9e7b63e027dee824ff11cb721cb90d767
46f78d2d8052fb5508dbc38e44ab6482caed76d5
refs/heads/master
2022-06-10T00:47:23.128829
2022-06-01T18:06:52
2022-06-01T18:06:52
189,889,876
0
0
null
null
null
null
UTF-8
Python
false
false
2,194
py
from kivy.clock import Clock from kivy.uix.screenmanager import Screen from kivy.uix.label import Label from kivy.uix.button import Button from kivy.uix.textinput import TextInput from kivy.uix.gridlayout import GridLayout from kivy.core.window import Window from scrollableLabel import ScrollableLabel import os import socket #this page is the page is supposed to display the commands sent by the server and #displays their response and in its core the ClientReverseShell will perform its function(executing the commnand on the client machine) class ClientRecvCommPage(GridLayout): def __init__(self,MainApp,**kwargs): super().__init__(**kwargs) self.MainApp = MainApp self.cols = 1 self.pageHead = Label(text="The commands sent to your machine") self.CommAndRes = ScrollableLabel() self.add_widget(self.pageHead) self.add_widget(self.CommAndRes) def recvAndExecComm(self): while self.MainApp.gui_running: try: self.MainApp.client.exec_command() if self.MainApp.client.comm_to_exec != "pwd": self.CommAndRes.updateContent(f"\n[color=00FF00]{os.getcwd()}${self.MainApp.client.comm_to_exec}[/color]\n[color=FF0000]{self.MainApp.client.comm_res}[/color]") except ValueError: self.MainApp.client.sock.close() self.pageHead.text = "The server may have been shut down" self.returnToConnectPageUsingButton() break except socket.error as err : err_msg = f"Networking error: {err}" print(err_msg) self.pageHead.text = err_msg self.returnToConnectPageUsingButton() def returnToConnectPageUsingButton(self): #adding a button to return back to the prev page using it returnButton = Button(text="Return to connect page") def returnButtonFunc(*_): self.MainApp.screen_manager.remove_widget(self.MainApp.screen) self.MainApp.screen_manager.current = "ClientConnectToServer" returnButton.bind(on_press=returnButtonFunc) self.add_widget(returnButton)
[ "k.elozeiri@gmail.com" ]
k.elozeiri@gmail.com
96afd9352f0dbd99372abcdb178f7d1bea36dcbe
2f22609355aa0f2bf69a26b24fa80d818ecc7cbe
/PYHcsc/pachong/text3.py
cb8449bd6d8d9370fb57f24931ab8879ccd14522
[]
no_license
mgGummy/PYH
d5c809ca9dfa408fbafd6f03c4fdf2dec5f78de0
5dbb367126504d532bca95850261d44a474867e3
refs/heads/master
2023-04-21T17:58:31.739241
2021-04-20T03:41:19
2021-04-20T03:41:19
343,682,555
0
0
null
null
null
null
UTF-8
Python
false
false
659
py
#-*- codeing = utf-8 -*- #@Time : 2021/3/28 10:54 #@Author : cscnb #@File : text3.py #@Software : PyCharm #KFC地点 import requests if __name__ == '__main__': url = 'http://www.kfc.com.cn/kfccda/ashx/GetStoreList.ashx?op=keyword' data = { 'cname':'', 'pid':'', 'keyword': '深圳', 'pageIndex': '1', 'pageSize': '10' } #UA伪装 headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36 Edg/89.0.774.56' } re=requests.post(url=url,data=data,headers=headers) re_text=re.text print(re_text)
[ "74232718+mgGummy@users.noreply.github.com" ]
74232718+mgGummy@users.noreply.github.com
41a37ac6032938be9a1bea9a1c62660c9002a43d
6e27704230e25b2a34d43e4247e7ebd343998a3c
/rando_project/rando_project/settings.py
d32acbc7a62a8552ee319c5aed9c0b6fa504299e
[]
no_license
C432/djangoProjects
9b3437a49829a9f3c9378be9987fd0f91b3b908c
81e0826f2f26c22dfe652b8af3460f43a9a233cb
refs/heads/master
2020-03-11T05:45:05.582509
2018-04-16T22:24:46
2018-04-16T22:24:46
129,811,857
0
3
null
null
null
null
UTF-8
Python
false
false
3,137
py
""" Django settings for rando_project project. Generated by 'django-admin startproject' using Django 1.10. For more information on this file, see https://docs.djangoproject.com/en/1.10/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.10/ref/settings/ """ import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'h5ram1ap#^x$swf9o!==ukdxq6#v5v&9k1g#dd)ivcjrb=a1f_' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'apps.rando_app', '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 = 'rando_project.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'rando_project.wsgi.application' # Database # https://docs.djangoproject.com/en/1.10/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } # Password validation # https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] # Internationalization # https://docs.djangoproject.com/en/1.10/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.10/howto/static-files/ STATIC_URL = '/static/'
[ "rclewis432@gmail.com" ]
rclewis432@gmail.com
bb54c000d01fac6c0780980db160d50201e59a2a
94833ddcca6fbcabdb49a13c7e79df37378265c4
/exercismdotio/python/etl/etl_test.py
eb9d5e07e3985ce07f49f447886dc8d4bceded8a
[]
no_license
asweigart/blankeditor
adc1a9e4372917c70c968e1ea72b3869112d81a3
461189a3e1e7d585b76e031d075fe3802f3aa391
refs/heads/master
2023-03-16T22:51:19.220898
2017-01-24T04:27:56
2017-01-24T04:27:56
69,526,062
5
3
null
null
null
null
UTF-8
Python
false
false
1,343
py
import unittest import etl class TransformTest(unittest.TestCase): def test_transform_one_value(self): old = {1: ['WORLD']} expected = {'world': 1} self.assertEqual(expected, etl.transform(old)) def test_transform_more_values(self): old = {1: ['WORLD', 'GSCHOOLERS']} expected = {'world': 1, 'gschoolers': 1} self.assertEqual(expected, etl.transform(old)) def test_more_keys(self): old = {1: ['APPLE', 'ARTICHOKE'], 2: ['BOAT', 'BALLERINA']} expected = { 'apple': 1, 'artichoke': 1, 'boat': 2, 'ballerina': 2 } self.assertEqual(expected, etl.transform(old)) def test_full_dataset(self): old = { 1: "AEIOULNRST", 2: "DG", 3: "BCMP", 4: "FHVWY", 5: "K", 8: "JX", 10: "QZ", } expected = { "a": 1, "b": 3, "c": 3, "d": 2, "e": 1, "f": 4, "g": 2, "h": 4, "i": 1, "j": 8, "k": 5, "l": 1, "m": 3, "n": 1, "o": 1, "p": 3, "q": 10, "r": 1, "s": 1, "t": 1, "u": 1, "v": 4, "w": 4, "x": 8, "y": 4, "z": 10 } self.assertEqual(expected, etl.transform(old)) if __name__ == '__main__': unittest.main()
[ "asweigart@gmail.com" ]
asweigart@gmail.com
fb67ebc3453d08b20826ff1882cc8e5977c08014
83f276845d5069712bfd32841b9560bb552e977a
/functions/register.py
8b879b004ff266d1f80585bb7a38d7a5b3360694
[]
no_license
ydishxjehzkudid/tg-botnet
16d31ce39cabe3c91016a590c26d4d13c36f7e0c
6bfd858924ab24aedbe0625afa8254912851ac76
refs/heads/main
2023-07-28T23:29:08.044055
2021-09-11T15:22:05
2021-09-11T15:22:05
405,234,320
0
0
null
null
null
null
UTF-8
Python
false
false
433
py
from telethon.sync import TelegramClient import os, sys def main(api_id, api_hash): phone = input("phone number ➜ ") session = str(len(os.listdir("sessions")) + 1) client = TelegramClient(session, api_id, api_hash) print("Sending verify code...") client.sign_in(phone) code = input("verify code ➜ ") client.sign_in(phone, code) return os.execl(sys.executable, sys.executable, *sys.argv)
[ "noreply@github.com" ]
ydishxjehzkudid.noreply@github.com
ef883e6bac67ab38649f0173426af4fe3e11d8a8
17bac9555fa83a4ca2f592a11096d7fecc3ec61f
/OSMKerasEnsemble.py
531cc70567f5f5c4e769eb458f6ecb3af04098b2
[ "MIT" ]
permissive
kellerberrin/OSM-QSAR
84f2be9bb22a5fa5e4970e84860af4673d00cb1c
3cdc411ee3f9a3cea178898171e0a57fb5282e40
refs/heads/master
2021-01-19T21:28:48.561869
2017-06-03T07:06:21
2017-06-03T07:06:21
82,504,529
2
0
null
null
null
null
UTF-8
Python
false
false
8,244
py
# MIT License # # Copyright (c) 2017 # # 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 NON INFRINGEMENT. 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. # # # Python 2 and Python 3 compatibility imports. from __future__ import absolute_import, division, print_function, unicode_literals from six import with_metaclass import copy import sys import os import numpy as np from sklearn.utils import shuffle from keras.models import Sequential from keras.layers import Dense from keras.layers import Dropout from keras.layers import normalization, BatchNormalization from keras.regularizers import l2, l1_l2 from keras.layers.noise import GaussianDropout, GaussianNoise from keras.models import load_model from keras.constraints import maxnorm from keras.optimizers import SGD, Adam, Adagrad, Adadelta from keras.utils import np_utils #from keras.utils.visualize_util import plot import keras.backend as backend from OSMBase import ModelMetaClass # The virtual model class. from OSMKerasBase import KerasClassifier from OSMKerasDragon import KlassBinaryDragon, KlassIonDragon, TruncIonDragon from OSMKerasFingerprint import KlassIonMaccs, KlassIonMorgan, KlassBinaryMorgan from OSMKerasCoulomb import CoulombMatrix, CoulombConvolution from OSMModelData import OSMModelData from OSMSKLearnClassify import OSMSKLearnLOGC, OSMSKLearnNBC # All The SKLearn Classifiers for the meta NN # ================================================================================================ # A meta pattern classifier, everything and the kitchen sink, used for model development. # ================================================================================================ class EnsembleSequential(with_metaclass(ModelMetaClass, KerasClassifier)): def __init__(self, args, log): super(EnsembleSequential, self).__init__(args, log) # Define the model data view. # Define the model variable types here. Documented in "OSMModelData.py". self.arguments = {"DEPENDENT": {"VARIABLE": "ION_ACTIVITY", "SHAPE": [3], "TYPE": OSMModelData.CLASSES} , "INDEPENDENT": [{"VARIABLE": "DRAGON", "SHAPE": [1666], "TYPE": OSMModelData.FLOAT64} ] } self.ensembles = self.model_define_ensemble(args, log) def model_define_ensemble(self, args, log): ensemble_file_list = [ { "File": "Run1", "Epochs" : 400 }, {"File": "Run2", "Epochs": 260}, {"File": "Run3", "Epochs": 220}, {"File": "Run4", "Epochs": 220}, {"File": "Run5", "Epochs": 260}, {"File": "Run6", "Epochs": 280}, {"File": "Run7", "Epochs": 280}, {"File": "Run8", "Epochs": 340}, {"File": "Run9", "Epochs": 340}, {"File": "Run10", "Epochs": 200} ] ensembles = [] for ensemble_file in ensemble_file_list: ensemble_args = copy.deepcopy(args) # ensure that args cannot be side-swiped. ensemble_args.indepList = ["DRAGON"] ensemble_args.dependVar = "ION_ACTIVITY" ensemble_args.train = 0 ensemble_args.epoch = ensemble_file["Epochs"] ensemble_args.loadFilename = os.path.join(ensemble_args.postfixDirectory, ensemble_file["File"]) ensembles.append(KlassIonDragon(ensemble_args, log)) return ensembles def model_ensemble_train(self): for ensemble in self.ensembles: ensemble.initialize(self.raw_data) def model_name(self): return "Ensemble DNN Classifier" def model_postfix(self): # Must be unique for each model. return "ion_ens" def model_description(self): return ("A Neural Network that uses an ensemble of other classifiers as input. \n" "The other classification models are pre-trained") def model_define(self): # Defines the modified sequential class with regularizers defined. self.model_ensemble_train() return self.model_arch() def model_arch(self): # Defines the modified sequential class with regularizers defined. model = Sequential() dropout_param = 0.2 activation = "relu" initializer = "uniform" adam = Adam(lr=0.0005, beta_1=0.9, beta_2=0.999, epsilon=5e-09) model.add(Dense(8, input_dim=len(self.ensembles), kernel_initializer=initializer, activation=activation, kernel_constraint=maxnorm(3))) model.add(Dropout(dropout_param)) model.add(Dense(16, kernel_initializer=initializer, activation=activation, kernel_constraint=maxnorm(3))) model.add(Dropout(dropout_param)) model.add(Dense(16, kernel_initializer=initializer, activation=activation, kernel_constraint=maxnorm(3))) model.add(Dropout(dropout_param)) model.add(Dense(3, activation = "softmax", kernel_initializer="normal")) model.compile(loss="categorical_crossentropy", optimizer=adam, metrics=["accuracy"]) return model def model_prediction(self, data): predictions = self.model.predict_classes(self.input_probability(data), verbose=0) classes = self.model_enumerate_classes() class_list = [] for predict in predictions: class_list.append(classes[predict]) return {"prediction": class_list, "actual": data.target_data()} def model_evaluate(self, data): classes = self.model_enumerate_classes() class_list = data.target_data() index_list = [] for a_class in class_list: index_list.append(classes.index(a_class)) binary_labels = np_utils.to_categorical(index_list) score = self.model.evaluate(self.input_probability(data), binary_labels, verbose=0) return score def model_probability(self, data): # probabilities are returned as a numpy.shape = (samples, classes) prob =self.model.predict_proba(self.input_probability(data)) prob_list = list(prob) return {"probability": prob_list} def train_epoch(self, epoch): classes = self.model_enumerate_classes() class_list = self.data.training().target_data() index_list = [] for a_class in class_list: index_list.append(classes.index(a_class)) binary_labels = np_utils.to_categorical(index_list) hist = self.model.fit(self.input_probability(self.data.training()), binary_labels, validation_split=self.args.holdOut, epochs=epoch, verbose=1) self.train_history("model_aux.csv", hist.history, epoch) def epoch_read(self, epoch): self.model_ensemble_train() file_name = self.args.loadFilename + "_" + "{}".format(epoch) + ".krs" self.log.info("KERAS - Loading Trained %s Model in File: %s", self.model_name(), file_name) model = load_model(file_name) return model def input_probability(self, data): prob_list = [] for ensemble in self.ensembles: prob = ensemble.model.predict_proba(data.input_data()) prob = np.asarray(prob) prob_list.append(prob[:,0]) prob_columns = np.column_stack(prob_list) return prob_columns
[ "james.duncan.mcculloch@gmail.com" ]
james.duncan.mcculloch@gmail.com
7418f34731694107c8a9a766757898df186dc261
98b76260f5c31563aa40e76c412be514c1844fc2
/fHDHR_web/api/settings.py
a4fcf1972588de1780c041f6de66faceafd4cbb7
[ "WTFPL" ]
permissive
DanAustinGH/fHDHR_Locast
cb54b235200a6123213853a133d6231df3b3a1ea
002117b666ad650c523aedb0209f1c996d576169
refs/heads/main
2023-02-15T20:27:21.141592
2021-01-05T19:09:35
2021-01-05T19:09:35
327,135,296
0
0
WTFPL
2021-01-05T22:28:13
2021-01-05T22:28:13
null
UTF-8
Python
false
false
1,386
py
from flask import request, redirect import urllib.parse class Settings(): endpoints = ["/api/settings"] endpoint_name = "api_settings" endpoint_methods = ["GET", "POST"] def __init__(self, fhdhr): self.fhdhr = fhdhr def __call__(self, *args): return self.get(*args) def get(self, *args): method = request.args.get('method', default="get", type=str) redirect_url = request.args.get('redirect', default=None, type=str) if method == "update": config_section = request.form.get('config_section', None) config_name = request.form.get('config_name', None) config_value = request.form.get('config_value', None) if not config_section or not config_name or not config_value: if redirect_url: return redirect(redirect_url + "?retmessage=" + urllib.parse.quote("%s Failed" % method)) else: return "%s Falied" % method if config_section == "origin": config_section = self.fhdhr.config.dict["main"]["dictpopname"] self.fhdhr.config.write(config_section, config_name, config_value) if redirect_url: return redirect(redirect_url + "?retmessage=" + urllib.parse.quote("%s Success" % method)) else: return "%s Success" % method
[ "github@deathbybandaid.net" ]
github@deathbybandaid.net
ed61c1f0260aa76c5c67b5bcc7a0bef382d999d1
b8686c3276a22a773135dfabcb775dace1b32d17
/beanMachSim2.py
3f4d1f7383f03667b2f363e0c8ef10f258c9a967
[]
no_license
jacobmorra/beanMachSim
cd91d309cd939d4505612a768b9ed3d4b1f8f821
ced86eb2479416d05515bbfbafa7d5fcf730f7b7
refs/heads/master
2020-04-06T04:42:05.457399
2017-04-23T00:47:05
2017-04-23T00:47:05
82,877,845
0
0
null
null
null
null
UTF-8
Python
false
false
2,700
py
import random as r import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation #have n bins, n-1 pins at bottom row, then n-2, n-3... class beanMachSim(): def __init__(self, numBalls): self.numBalls = numBalls self.numRows = 20 self.numBins = self.numRows+1 self.binContents = np.zeros((self.numBins,), dtype=np.int) self.ballPos = 0 def theorResult(self): return True def moveRight(self): p = np.random.rand() if p > 0.5 and p < 1: #print p return True elif p > 0 and p <= 0.5: #print p return False def dropBall(self): self.ballPos = (self.numBins/2)+1 #reset ball pos to middle b/w 0 and 9 print "start @ middle: ", self.ballPos for i in range(self.numRows+1): print "row: ", i right = self.moveRight() if right is True: if self.ballPos == self.numBins-1: print "ball @ 9" pass elif self.ballPos < self.numBins-1: print "move right" self.ballPos += 1 if right is False: if self.ballPos == 0: print "ball @ 0" pass elif self.ballPos > 0: print "move left" self.ballPos -= 1 print self.ballPos return self.ballPos def dropAllBalls(self): while self.numBalls > 0: self.binContents[self.dropBall()] += 1 self.numBalls -= 1 def update_hist(self): plt.cla() #clear axis for i in self.binContents: self.binContents[i] +=1 plt.hist(self.binContents) def main(): import random as r import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation q = beanMachSim(1000) q.dropAllBalls() print q.binContents numFrames = 10 #plt.bar(range(0, q.numBins), q.binContents) #plt.show() number_of_frames = 10 fig = plt.figure() ax1=fig.add_subplot(1,1,1) #hist = plt.hist(q.binContents[0]) def animate(i): a=beanMachSim(100) x=[] for i in range(a.numBins): x.append(i) while a.numBalls > 0: print a.binContents a.binContents[a.dropBall()] += 1 a.numBalls -= 1 print a.binContents #plt.hist(a.binContents) ax1.plot(x,a.binContents) ani = animation.FuncAnimation(fig, animate, interval = 100) plt.show() if __name__ == "__main__": main()
[ "jacob.morra@uoit.net" ]
jacob.morra@uoit.net
4b32c70f537ca7f7af7b6fe05cd69ef92cd2fe9e
6c747d71555eed0f50c04614950dbca327323f15
/settings.py
e2d379f06be86811cd1d1df3bc38be93f5031e95
[]
no_license
blarneyosullivan/flask_blog
f8974c23a7d6e057cd633565634a4ed372640e6b
526f3f028ddeb6b4a4ea837f462c7fa8f21dd6b0
refs/heads/master
2021-01-17T10:30:47.362030
2016-06-14T11:20:50
2016-06-14T11:20:50
57,325,181
0
0
null
null
null
null
UTF-8
Python
false
false
499
py
import os SECRET_KEY = "-\x85\x99Q5\x89\xe7@\x06\xd3\xa6=G\xcf k\xce6'\x16\xd6\xbb\xe6q" DEBUG = True DB_USERNAME = 'blarneyosullivan' DB_PASSWORD = '' BLOG_DATABASE_NAME = 'blog' DB_HOST = os.getenv('IP','0.0.0.0') DB_URI = "mysql+pymysql://%s:%s@%s/%s" % (DB_USERNAME, DB_PASSWORD, DB_HOST, BLOG_DATABASE_NAME) SQLALCHEMY_DATABASE_URI = DB_URI SQLALCHEMY_TRACK_MODIFICATIONS = True UPLOADED_IMAGES_DEST = '/home/ubuntu/workspace/flask_blog/static/images' UPLOADED_IMAGES_URL = '/static/images/'
[ "blarneyosullivanbloggs@gmail.com" ]
blarneyosullivanbloggs@gmail.com
e114ba8f5c50330232bf96fade678a11abb13e91
1178f1445ab0be78a1ff1865ef57d8af1b8c0e56
/LearnDistance/refactored/old_files/testTensorBoard.py
666cf1b9814bbaa04eb56c6b9dc1bd6cdc3d23b9
[]
no_license
GiannisGl/MasterThesis
2e22eae9389436a910f8af8d5787baf54e7f35e8
9af4c2976c4dd645ecb61fa0938e9fb7979b2888
refs/heads/master
2021-04-09T15:02:04.603535
2019-01-02T00:29:12
2019-01-02T00:29:12
125,541,194
0
0
null
null
null
null
UTF-8
Python
false
false
2,429
py
import torch import torchvision import torchvision.transforms as transforms from tensorboardX import SummaryWriter from featuresModel import featsLenetFix, featsLenetFull, featsAE from helperFunctions import * import sys sys.path.insert(0, '../../trainModels') trainstep = 3 delta = 5 lamda = 1 Nsamples = 1000 nAug = 10 modelname = "featsModelLearnDistanceDistLeNetNoNormAugmentationDelta50Lamda1" # modelname = "featsModelLearnDistanceDistLeNetNoNormAugmentation%iDelta%iLamda%i" % (nAug, delta, lamda) modelfolder = "trainedModels" featsModel = load_model(featsLenetFull, modelfolder, modelname, trainstep, pretrained=False) featsModel.cpu() transform = transforms.Compose( [transforms.ToTensor()]) if torch.cuda.is_available(): datafolder = "/var/tmp/ioannis/data" else: datafolder = "../../data" transform = transforms.Compose([transforms.ToTensor()]) train_dataset = torchvision.datasets.MNIST(root=datafolder, train=True, download=False, transform=transform) train_subset = torch.utils.data.dataset.Subset(train_dataset, range(Nsamples)) trainloader = torch.utils.data.DataLoader(train_subset, batch_size=Nsamples, shuffle=False, num_workers=0) test_dataset = torchvision.datasets.MNIST(root=datafolder, train=False, download=False, transform=transform) test_subset = torch.utils.data.dataset.Subset(test_dataset, range(Nsamples)) testloader = torch.utils.data.DataLoader(test_subset, batch_size=Nsamples, shuffle=False, num_workers=0) # Train Visualization print('visualizing..') writerEmb = SummaryWriter(comment='%s_Iter%i_mnist_embedding_train' % (modelname, trainstep), log_dir='embeddings3') iterTrainLoader = iter(trainloader) input, label = next(iterTrainLoader) output = featsModel.forward(input) output = torch.squeeze(output) print(output.size()) # output = torch.cat((output, torch.ones(len(output), 1)), 1) # input = input.to(torch.device("cpu")) # save embedding writerEmb.add_embedding(output, metadata=label.data, label_img=input.data, global_step=14) # Test Visualization print('visualizing..') iterTestLoader = iter(testloader) input, label = next(iterTestLoader) output = featsModel.forward(input) output = torch.squeeze(output) print(output.size()) # output = torch.cat((output, torch.ones(len(output), 1)), 1) # input = input.to(torch.device("cpu")) # save embedding writerEmb.add_embedding(output, metadata=label.data, label_img=input.data, global_step=15) writerEmb.close()
[ "ioannis.glampedakis@students.unibe.ch" ]
ioannis.glampedakis@students.unibe.ch
cc80b8774b1bc6cf8f038f4f1585bb89f36e1c8c
b7fe5aefc01f45170d2cfc2f4c3ca2c14c2778dd
/csgo-ui-cv/src/initJson.py
114f61d29aec7bc46ce466699245d6ce7783b314
[]
no_license
mortenoj/deep-learning-project
ed2a0996682762b6d12b7bf922c32c6de4dd1832
402e1af3dbb9b1e89d4fc3607b0cf9818f81a13d
refs/heads/master
2023-04-13T20:30:49.580820
2019-11-23T14:34:16
2019-11-23T14:34:16
218,812,195
0
0
null
2023-03-25T00:07:51
2019-10-31T16:36:48
Python
UTF-8
Python
false
false
354
py
import glob import json data = [] for file in glob.glob("icons/*.png"): if "_dark" in file: continue name = file.replace("icons/", "").replace(".png", "") data.append({ 'name': name, 'path': file, 'type': '', 'cost': 0, }) with open('data.json', 'w') as outfile: json.dump(data, outfile)
[ "morten@omholt-jensen.com" ]
morten@omholt-jensen.com
8f1f674218ed67a9453406ca5cdeede7c1220ca6
3dab3662af42f6b33f8e16724949261129ed8f8f
/Python/task43.py
ace6bfafc0db962c945230240c03343f6fcfe5a6
[]
no_license
kikiwongweb/kikiwongweb.github.io
81f7d922c9e9dc1464688362de448f055fe9b729
dbb0b55f47d26a4747ce9aa9049777c8ddd275d7
refs/heads/master
2023-09-02T19:24:48.413096
2023-08-25T08:21:21
2023-08-25T08:21:21
202,672,757
0
0
null
null
null
null
UTF-8
Python
false
false
66
py
thistuple = ["scone ", "cupcake", "muffins"] print(thistuple[1])
[ "wkiyuet@gmail.com" ]
wkiyuet@gmail.com
a787047bff0c334d700d0bb2702386844d93b971
a4646f7f0204aadbb57be000825f22c545c0ca18
/groups_service/db.py
9c235da95555e935a4f4b996e16ecbe9e17fad41
[]
no_license
lv-412-python/groups-service-repo
7d883d9d43c8585d4660cb6819ce5526ab17d031
c5c9a8f0f33e87ad95555e0340ce02086c471fd0
refs/heads/develop
2022-12-10T11:00:35.022035
2019-08-15T11:59:44
2019-08-15T11:59:44
192,919,017
0
0
null
2022-12-08T05:53:21
2019-06-20T12:49:27
Python
UTF-8
Python
false
false
290
py
"""Database connection.""" from flask_migrate import Migrate from flask_sqlalchemy import SQLAlchemy from groups_service import APP from groups_service.config.dev_config import DevelopmentConfig APP.config.from_object(DevelopmentConfig) DB = SQLAlchemy(APP) MIGRATE = Migrate(APP, DB)
[ "hydh95@gmail.com" ]
hydh95@gmail.com
69fd4e746a10a6f382f1d36d5fc74e9be78fe04b
cd9c3bfe77cb1673746345522acc77ec990242fc
/composite.py
b85e06f25246e5e1d2d1ce9406c576f21a1675e4
[]
no_license
tjuls123/DesignPattern
18b7bbab1bb086019a1c69f87690e98912e3a585
08bf6210d68b4115fe8d575eae9e023d1f4f33da
refs/heads/master
2022-09-22T02:21:48.607400
2020-05-28T13:38:17
2020-05-28T13:38:17
259,825,527
0
1
null
null
null
null
UTF-8
Python
false
false
1,757
py
# -*- coding:utf-8 -*- # Author: lsn5884@corp.netease.com # Date : 2020/5/26 # Note : 组合模式 """ 将对象组合成树形结构以表示‘部分-整体’的层次结构,Composite使得用户对单个对象和组合对象的使用具有一致性 Composite模式的关键是一个抽象类,它既可以表示基本图元,也可以表示图元的容器 参与者: Component 为组合中的对象申明接口 在适当的情况下,实现所有类共有接口的缺省行为 申明一个接口用于管理子组件 Leaf: 表示叶子节点,定义图元的行为 Composite: 管理子组件 """ class Component(object): def __init__(self, name): self.name = name def add(self, component): """Composite 的管理子节点的方法,添加component""" raise NotImplementedError def remove(self, component): """移除component""" raise NotImplementedError def show_name(self): """叶子节点的具体方法""" print self.name class LeafComponent(Component): def __init__(self, name): super(LeafComponent, self).__init__(name) def add(self, component): raise NotImplementedError def remove(self, component): raise NotImplementedError class Composite(Component): def __init__(self, name): super(Component, self).__init__(name) self.child_components = [] def add(self, component): self.child_components.append(component) def remove(self, component): self.child_components.remove(component) if __name__ == '__main__': c = Composite('Composite1') c.add(LeafComponent('component1')) c2 = Composite('Composite2') c.add(c2) c2.add(LeafComponent('asdf'))
[ "tjuls163@163.com" ]
tjuls163@163.com
dafc7a05ccff7145ce835329a4d70a8c20a5a1b0
377d86194fd6d23c8ef3df3e6f7d90092dd8f9b4
/workout_tracker/core/views.py
6d2e25e1e49080b2d8ec1710997bbc07a3957c4b
[ "MIT" ]
permissive
e-dang/Workout-Tracker
f20f44b012e895244bad413a46103415ffae5732
00a27597ea628cff62b320d616f56b2df4f344a0
refs/heads/master
2022-12-28T07:49:34.179307
2020-10-12T20:48:28
2020-10-12T20:48:28
293,937,958
0
0
null
null
null
null
UTF-8
Python
false
false
409
py
from rest_framework.viewsets import GenericViewSet from rest_framework import mixins class ListRetrieveUpdateDestroyViewSet(mixins.ListModelMixin, mixins.RetrieveModelMixin, mixins.UpdateModelMixin, mixins.DestroyModelMixin, GenericViewSet): pass
[ "edang830@gmail.com" ]
edang830@gmail.com
5d68b25c00bf45fe30b2bb744c6a85ac95b2bf0d
8ac1b76e4e8f3d74800d0b8cd5b9e452150daac3
/gaffer/cli/commands/lookup_jobs.py
272b21af62ddb94eea500a48073ac4637e096fb4
[ "MIT", "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference", "Unlicense", "BSD-3-Clause" ]
permissive
david-caro/gaffer
a721f2306554e93712b71502909d5fe56327ae3d
f69adfd5f674cecd2bcd95bc7917f4aa77a5a89d
refs/heads/master
2023-08-19T10:57:51.431467
2013-10-19T12:49:16
2013-10-19T12:49:16
17,575,380
0
0
NOASSERTION
2023-08-14T21:35:19
2014-03-09T22:31:28
Python
UTF-8
Python
false
false
1,605
py
# -*- coding: utf-8 - # # This file is part of gaffer. See the NOTICE for more information. from ...lookupd.client import LookupServer from .base import Command import pyuv class LookupJobs(Command): """ usage: gaffer lookup:jobs (-L ADDR|--lookupd-address=ADDR)... -h, --help -L ADDR --lookupd-address=ADDR lookupd HTTP address """ name = "lookup:jobs" short_descr = "list all jobs in lookupd servers" def run(self, config, args): lookupd_addresses = set(args['--lookupd-address']) loop = pyuv.Loop.default_loop() all_jobs = {} for addr in lookupd_addresses: s = LookupServer(addr, loop=loop, **config.client_options) resp = s.jobs() for job in resp['jobs']: job_name = job['name'] if job_name in all_jobs: all_jobs[job_name] = list( set(all_jobs[job_name] + job['sources']) ) else: all_jobs[job_name] = job['sources'] loop.run() print("%s job(s) found\n" % len(all_jobs)) for job_name, sources in all_jobs.items(): lines = ["=== %s" % job_name] for source in sources: name = source['node_info']['name'] version = source['node_info']['version'] origin = source['node_info']['origin'] lines.append("%s - name: %s, protocol: %s" % (origin, name, version)) lines.append("") print("\n".join(lines))
[ "bchesneau@gmail.com" ]
bchesneau@gmail.com
924428b72cc88b244685fd2e7a2944bde27fc0f8
fbfde86616755a99f37812112342469a5da8930a
/learning_users/basic_app/migrations/0001_initial.py
7fc9b6ce0de26b0de0b5c64036bf0d5456e686a0
[]
no_license
Denisijcu/django-deployment-example
e23d517736e5959fb9a7982046896d0f7c1c2b3e
14a140b21d7200e4f208a50b0f2b33ed3d219baa
refs/heads/master
2020-03-07T06:10:26.361924
2018-03-29T16:20:00
2018-03-29T16:20:00
127,314,803
0
0
null
null
null
null
UTF-8
Python
false
false
845
py
# Generated by Django 2.0.2 on 2018-03-29 13:07 from django.conf import settings from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): initial = True dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( name='UserProfileInfo', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('portfolio_site', models.URLField(blank=True)), ('profile_pic', models.ImageField(blank=True, upload_to='profile_pics')), ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], ), ]
[ "dsanchez@armellini.com" ]
dsanchez@armellini.com
93119f66d54d058edd970d86595e73eedffac4ac
8ea98c14a7097448e56d0256458a9b944176e73d
/was-projekti/lib/python3.7/importlib/_bootstrap.py
a3af0e6ece96b214f142d5c06e9a82662e732e1c
[]
no_license
ronttonen/was_ryhma_tyo
03e5719be27cc72de41e8f9e1e7e50a3db301ffe
4a3f874aacc2426d8927fb14b64e9d23d6618889
refs/heads/master
2020-04-30T01:53:36.666710
2019-03-26T18:23:40
2019-03-26T18:23:40
176,542,879
0
0
null
null
null
null
UTF-8
Python
false
false
64
py
/Users/roni.ahti/anaconda3/lib/python3.7/importlib/_bootstrap.py
[ "roni.ahti@quru.fi" ]
roni.ahti@quru.fi
864e386240e97b5099dbc6a37b8d6b74b8c64332
1ac57ac40a64f1a2f81d913d3c3d0b563dfb7d14
/src/synchronization.py
d8cf425aa84aafff0fee78073ccfd5d1d243e1d3
[]
no_license
krupatomasz/dtn-sync
20a92caf93cbfff5e30f28118496e170d7858f6f
89d1c468876f42a69a73343c9547674f5d7f8e59
refs/heads/master
2020-06-19T08:21:00.020338
2019-06-22T17:02:09
2019-06-22T17:02:09
196,635,952
0
0
null
2019-07-12T19:39:52
2019-07-12T19:39:52
null
UTF-8
Python
false
false
453
py
import communication class UpdateMetric: LONGEST_CHAIN = 1 NEWEST = 2 class SyncWorker: def __init__(self, path, conflict_resolution_callback, update_metric=UpdateMetric.LONGEST_CHAIN): self.conflict_resolution_callback = conflict_resolution_callback self.update_metric = update_metric self.comm = communication.Communicator(self._on_file_received) def _on_file_received(self, file): print("XXX")
[ "chorig9@gmail.com" ]
chorig9@gmail.com
ca4b8206a1c14bb172cf7b8b72f33bc51eec827c
4f9335717b02c4d3dc697ff051d34455be45a9d1
/pytorch_codes/casnet2_mixed_alldirs/dataload_unet_mixed.py
0279d340e3b9d912af0ca701e599a145be2b1436
[]
no_license
sunhongfu/scripts
7df6bf7eb922a58fba2cdef187ac2d5bb19f8357
6d0239e05cea73d9413acca1bd4ecdcc22d00404
refs/heads/master
2022-12-11T01:05:06.209578
2022-12-07T04:28:26
2022-12-07T04:28:26
63,374,060
4
1
null
null
null
null
UTF-8
Python
false
false
4,098
py
import numpy as np import nibabel as nib import torch from torch.utils import data import torch.nn.functional as F class yangDataSet(data.Dataset): def __init__(self, root, z_prjs_file): super(yangDataSet, self).__init__() self.root = root # self.list_path = list_path self.z_prjs_file = z_prjs_file z_prjs_arr = [line.strip().split(" ") for line in open(z_prjs_file)] # convert z_prjs into a dic z_prjs_keys = [z_prjs_arr[i][0] for i in range(0, len(z_prjs_arr))] z_prjs_values = [z_prjs_arr[i][1:4] for i in range(0, len(z_prjs_arr))] # z_prjs_dict = dict(zip(z_prjs_keys, z_prjs_values)) # get the number of files. self.img_ids = [i_id.strip() for i_id in z_prjs_keys] # print(self.img_ids) # get all fil names, preparation for get_item. # for example, we have two files: # 102-field.nii for input, and 102-phantom for label; # then image id is 102, and then we can use string operation # to get the full name of the input and label files. self.files = [] for name in self.img_ids: img_file = self.root + \ ("/alldirs_field/alldirs_field_%s.nii" % name) label_file = self.root + ("/alldirs_chi/alldirs_chi_%s.nii" % name) rot_file = self.root + \ ("/alldirs_rotation/alldirs_rot_mat_%s.nii" % name) inv_file = self.root + \ ("/alldirs_rotation/alldirs_inv_mat_%s.nii" % name) self.files.append({ "img": img_file, "label": label_file, "rot_mat": rot_file, "inv_mat": inv_file, "name": name }) # sprint(self.files) def __len__(self): return len(self.files) def __getitem__(self, index): datafiles = self.files[index] '''load the datas''' name = datafiles["name"] # nifti read codes. nibimage = nib.load(datafiles["img"]) niblabel = nib.load(datafiles["label"]) nibrot = nib.load(datafiles["rot_mat"]) nibinv = nib.load(datafiles["inv_mat"]) image = nibimage.get_data() label = niblabel.get_data() rot_mat = nibrot.get_data() inv_mat = nibinv.get_data() image = np.array(image) label = np.array(label) rot_mat = np.array(rot_mat) inv_mat = np.array(inv_mat) # convert the image data to torch.tesors and return. image = torch.from_numpy(image) label = torch.from_numpy(label) rot_mat = torch.from_numpy(rot_mat) inv_mat = torch.from_numpy(inv_mat) image = torch.unsqueeze(image, 0) label = torch.unsqueeze(label, 0) rot_mat = torch.unsqueeze(rot_mat, 0) inv_mat = torch.unsqueeze(inv_mat, 0) image = image.float() label = label.float() rot_mat = rot_mat.float() inv_mat = inv_mat.float() image = F.pad(image, (8, 8, 8, 8, 8, 8), "constant", 0) label = F.pad(label, (8, 8, 8, 8, 8, 8), "constant", 0) return image, label, rot_mat, inv_mat, name # before formal usage, test the validation of data loader. if __name__ == '__main__': DATA_DIRECTORY = '/Volumes/LaCie/CommQSM/invivo/data_for_training' DATA_LIST_PATH = '/Users/uqhsun8/Documents/MATLAB/scripts/pytorch_codes/image_unet_stack_prjs_alldirs_equalsize/z_prjs_alldirs.txt' Batch_size = 4 dst = yangDataSet(DATA_DIRECTORY, DATA_LIST_PATH) print(dst.__len__()) # just for test, so the mean is (0,0,0) to show the original images. # But when we are training a model, the mean should have another value # test code on personal computer: trainloader = data.DataLoader( dst, batch_size=Batch_size, shuffle=False, drop_last=True) for i, Data in enumerate(trainloader): image, label, rot_mat, inv_mat, name = Data print(i) if i % 1 == 0: print(name) print(image.size()) print(label.size())
[ "sunhongfu@gmail.com" ]
sunhongfu@gmail.com
4fa2247e444d092bd39cc8151730fac832136ec1
08cc2f0b3b87979460e2a63f0986beb418ba7747
/pursuite/bin/route53
4ef01015d473f339315e3295f8e617f0c84fb896
[]
no_license
yagna-tech/Staging-WFIMS-1
31d4c5323f80e2b334136b76d50a4db75faf0045
ac53d1ddafb987404570edb7a15d6db5daa2e3da
refs/heads/master
2016-08-03T08:49:04.120781
2015-04-15T08:06:17
2015-04-15T08:06:17
33,035,575
0
0
null
null
null
null
UTF-8
Python
false
false
178
#!/opt/pursuite/bin/python # EASY-INSTALL-SCRIPT: 'boto==2.27.0','route53' __requires__ = 'boto==2.27.0' import pkg_resources pkg_resources.run_script('boto==2.27.0', 'route53')
[ "lakshmi@yagna-tech.com" ]
lakshmi@yagna-tech.com
19eee7c510ffba8cd43392beb70aee1fdf596626
0a7d60f0f79fa6d00b3d99e42f4eb5bd84b5d147
/teuthology/test/test_get_distro_version.py
e93b9b62a67aaf02a8d02ac4d2eeb9ca08696a09
[]
no_license
yehudasa/teuthology
792bfdc8078be2e983b2fdf9d1b6744e92d99a92
59ee17dc1944d35966693369edff785c5e73dc1d
refs/heads/master
2021-01-15T20:57:11.704086
2014-05-30T14:59:36
2014-05-30T14:59:36
20,341,792
1
1
null
null
null
null
UTF-8
Python
false
false
1,827
py
from .. import misc as teuthology class Mock: pass class TestGetDistroVersion(object): def setup(self): self.fake_ctx = Mock() self.fake_ctx.config = {} self.fake_ctx_noarg = Mock() self.fake_ctx_noarg.config = {} self.fake_ctx_noarg.os_version = None def test_default_distro_version(self): #Default distro is ubuntu, default version of ubuntu is 12.04 self.fake_ctx.os_version = None distroversion = teuthology.get_distro_version(self.fake_ctx) assert distroversion == '12.04' def test_argument_version(self): self.fake_ctx.os_version = '13.04' distroversion = teuthology.get_distro_version(self.fake_ctx) assert distroversion == '13.04' def test_teuth_config_version(self): #Argument takes precidence. self.fake_ctx.os_version = '13.04' self.fake_ctx.config = {'os_version': '13.10'} distroversion = teuthology.get_distro_version(self.fake_ctx) assert distroversion == '13.04' def test_teuth_config_downburst_version(self): #Argument takes precidence self.fake_ctx.os_version = '13.10' self.fake_ctx.config = {'downburst' : {'distroversion': '13.04'}} distroversion = teuthology.get_distro_version(self.fake_ctx) assert distroversion == '13.10' def test_teuth_config_noarg_version(self): self.fake_ctx_noarg.config = {'os_version': '13.04'} distroversion = teuthology.get_distro_version(self.fake_ctx_noarg) assert distroversion == '13.04' def test_teuth_config_downburst_noarg_version(self): self.fake_ctx_noarg.config = {'downburst' : {'distroversion': '13.04'}} distroversion = teuthology.get_distro_version(self.fake_ctx_noarg) assert distroversion == '13.04'
[ "sandon@inktank.com" ]
sandon@inktank.com
7a6f1f9e78fc429569f97ddd2f0b02cafd7439af
41073cb6cb646503113db91a96d6a8db818ea409
/dir/management/commands/enforce_language_association.py
a264a2c9b8217167329c84be19689c3d694abad4
[]
no_license
Xangis/wbsrch
824a881e6455ac9e552c7826f414d4b8701bcc3d
f95fb65e54fce29e9d2157f66ce79c7f4da91639
refs/heads/master
2023-06-28T23:53:06.365752
2021-07-26T18:43:27
2021-07-26T18:43:27
52,846,758
1
0
null
null
null
null
UTF-8
Python
false
false
3,666
py
# -*- coding: utf-8 -*- from django.core.management.base import BaseCommand from dir.models import DomainInfo, language_list, SiteInfo from dir.utils import MoveSiteTo, GetSiteInfoModelFromLanguage class Command(BaseCommand): help = """ This command enforces language associations on all URLs in the database. Domains with a language tag could have made it into the main site_info table from a sync_crawls import or some other way. The puts things where they belong. """ def add_arguments(self, parser): parser.add_argument('-c', '--cleanup', default=False, action='store_true', dest='cleanup', help='Delete all non-English pages from language indexes if they are not tagged that language.') parser.add_argument('-l', '--language', default=None, action='store', dest='languages', help='Check this comma-seperated list of language codes, only works with -c. (default=all)') def handle(self, *args, **options): if options['cleanup']: if 'languages' not in options: languages = language_list else: languages = options['languages'].split(',') loglines = [] for language in languages: if language == 'en': continue deleted = 0 bad_domains = 0 good_domains = 0 print('Processing language {0}'.format(language)) site_model = GetSiteInfoModelFromLanguage(language) domains_to_check = site_model.objects.values_list('rooturl', flat=True).distinct().order_by('rooturl') for domain in domains_to_check: info = DomainInfo.objects.filter(url=domain).first() if not info or info.language_association != language: print('{0} is not {1}. Deleting.'.format(domain, language)) count = site_model.objects.filter(rooturl=domain).count() print('Deleting {0} pages.'.format(count)) deleted += count bad_domains += 1 site_model.objects.filter(rooturl=domain).delete() else: print('{0} is good.'.format(domain)) good_domains += 1 logline = '{0}: {1} domains were good and {2} were not. {3} pages were deleted.'.format(language, good_domains, bad_domains, deleted) loglines.append(logline) print(logline) for line in loglines: print(line) return domain_data = DomainInfo.objects.filter(language_association__in=language_list).exclude(language_association='en').order_by('url').values('url', 'language_association') print('Need to process {0} domains.'.format(len(domain_data))) count = 0 pages_moved = 0 for domain in domain_data: # print(domain) # {'url': '0000000000000.de', 'language_association': 'de'} pages = SiteInfo.objects.filter(rooturl=domain['url']) found = pages.count() if found: print('Need to move {0} pages to {1} for {2}'.format(found, domain['language_association'], domain['url'])) for page in pages: MoveSiteTo(page, domain['language_association']) pages_moved += 1 count += 1 if count % 10000 == 0: print('Processed {0} domains.'.format(count)) print('Processed {0} domains and moved {1} pages.'.format(count, pages_moved))
[ "jchampion@zetacentauri.com" ]
jchampion@zetacentauri.com
fe2805328e8c5860ae723a28a58e36986c45e932
38a7290136587c5fb6e1b8dec73df21c646bd301
/realCaraway/caraway/login/migrations/0021_auto_20180331_0635.py
10023a9717e18952904ea80fe4acd8bc352fc543
[ "MIT" ]
permissive
Arkham32/cmpt395
2447b1b3c27d6591f809bd848e685a62a461b207
d526ddf7a253ada94ba9682c009d33e45f7b5a90
refs/heads/master
2020-05-01T01:27:38.569285
2018-04-11T01:51:52
2018-04-11T01:51:52
null
0
0
null
null
null
null
UTF-8
Python
false
false
451
py
# Generated by Django 2.0.2 on 2018-03-31 06:35 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('login', '0020_auto_20180331_0631'), ] operations = [ migrations.RemoveField( model_name='parentcreation', name='last_login', ), migrations.RemoveField( model_name='parentcreation', name='password', ), ]
[ "asifr@mymacewan.ca" ]
asifr@mymacewan.ca
1c57565fe8552e752679d220837557441e8c8dbb
9307372654241cd7235132cb2b8153e5e7557ebd
/track/migrations/0007_auto_20210614_1644.py
e699f25d84bb03b7a9a0863a649f7834129585aa
[]
no_license
rohan-130/fitness-stats
faa87d018459b8f47f3aa6a27e8d385469aa61a4
06a63091d8359e2e56645e9290a47d2e33d31359
refs/heads/master
2023-06-15T22:24:22.390308
2021-07-13T08:28:50
2021-07-13T08:28:50
382,362,683
0
0
null
null
null
null
UTF-8
Python
false
false
1,344
py
# Generated by Django 3.1.6 on 2021-06-14 11:14 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('track', '0006_auto_20210614_1629'), ] operations = [ migrations.AlterField( model_name='plans', name='fri', field=models.CharField(max_length=5, null=True), ), migrations.AlterField( model_name='plans', name='mon', field=models.CharField(max_length=5, null=True), ), migrations.AlterField( model_name='plans', name='sat', field=models.CharField(max_length=5, null=True), ), migrations.AlterField( model_name='plans', name='sun', field=models.CharField(max_length=5, null=True), ), migrations.AlterField( model_name='plans', name='thu', field=models.CharField(max_length=5, null=True), ), migrations.AlterField( model_name='plans', name='tue', field=models.CharField(max_length=5, null=True), ), migrations.AlterField( model_name='plans', name='wed', field=models.CharField(max_length=5, null=True), ), ]
[ "rohanmodi@outlook.in" ]
rohanmodi@outlook.in
32c0b78505d9c4f93b6dbf211d52a7080cc44a51
1d3bcd3d8b2d9584792f67d5372bd61eff94d6fc
/superlists/superlists/settings.py
465c3b9b6a045e4876ada099b4470ded7f41dd1b
[]
no_license
goutham2027/pytdd
e4f37f151f98cb15eef71469dfb6f4da53c2ab1e
168be74af7ed1613aa3be9d774abb44f05639d8b
refs/heads/master
2021-01-13T12:44:42.980052
2016-11-02T11:15:18
2016-11-02T11:15:18
72,527,179
0
0
null
null
null
null
UTF-8
Python
false
false
3,108
py
""" Django settings for superlists project. Generated by 'django-admin startproject' using Django 1.10.2. For more information on this file, see https://docs.djangoproject.com/en/1.10/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.10/ref/settings/ """ import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'g0$)pe*jg(2rrbe7ersnd1uj0i()!$vyz-(+q$wx4a2c4szyy=' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'superlists.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'superlists.wsgi.application' # Database # https://docs.djangoproject.com/en/1.10/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } # Password validation # https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] # Internationalization # https://docs.djangoproject.com/en/1.10/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.10/howto/static-files/ STATIC_URL = '/static/'
[ "goutham2027@gmail.com" ]
goutham2027@gmail.com
31ee53755adac2a4f3f31998539b3588933a1b62
edc7d4acbc4cc3851422be34a60e7eaaf403f34d
/society/migrations/0002_recharge.py
dcda0b9e79801f13ce0ffa64e2ff6bec933b0d34
[]
no_license
CHENLiangxu/badminton-society
869bddfa971a98c1c9d8f749fc632435b88ca99d
b735c06fdbafb6ad53ffddab4b5ae1c5f03f73f7
refs/heads/master
2016-09-01T03:44:41.565268
2016-02-26T14:51:41
2016-02-26T14:51:41
50,294,662
0
1
null
2016-02-26T14:11:27
2016-01-24T15:48:06
JavaScript
UTF-8
Python
false
false
779
py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ('society', '0001_initial'), ] operations = [ migrations.CreateModel( name='Recharge', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('comment', models.CharField(max_length=200, null=True)), ('price', models.FloatField()), ('created_at', models.DateTimeField()), ('member', models.ForeignKey(to='society.Member')), ], options={ }, bases=(models.Model,), ), ]
[ "chenliangxu68@gmail.com" ]
chenliangxu68@gmail.com
014f5f97fdc07633f6db5a4021c23e1b80753136
91227a62ed0f36fe82f7a66ca76e686694ba2926
/python/file.py
0adffdba56482629ffe3e8159c60621a6e5b9f7a
[]
no_license
TY-sky/NOTE
48cf74df0ca786859e23d85d6a90662f5a983040
1b505fe0a5b659024277c2da8630b6cf62542ac2
refs/heads/master
2021-08-22T06:50:02.114077
2020-03-19T15:09:07
2020-03-19T15:09:07
135,244,400
0
0
null
null
null
null
UTF-8
Python
false
false
231
py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- ' a test module ' __author__ = 'TY' fpath = r'C:\py\test.ini' with open(fpath, 'a') as f: f.write('Hello, world!') with open(fpath, 'r') as f: s = f.read() print(s)
[ "986181043@qq.com" ]
986181043@qq.com
d2e0741b18952a435edfa1fa4ec20a5d9c97fc37
3bdd3312d4f26ed050222b38491c2091774c9ccc
/system/firstpart/urls.py
f86f1cd187bcb39be6b27bbf1fb49729444eb836
[]
no_license
vanesa1999/pythonProject16
f67a5026dfaf457a5c1298cb4917488786ef5a10
efe603f2a4100172b3cc654c54aefa2a6ed3dddd
refs/heads/master
2023-04-12T21:32:33.284936
2021-05-10T09:21:20
2021-05-10T09:21:20
365,985,525
0
0
null
null
null
null
UTF-8
Python
false
false
766
py
from django.db import models from django.contrib.auth.models import User Pozicionet= ['HR', 'Pergjegjes Departamenti', 'Punonjes Departamenti'] Gjinia= ['Femer', 'MAshkull'] Status= ['Aktiv', 'Joaktiv'] class Punonjes(models.Model): username= models.OneToOneField(User, null= True, on_delete=models.SET_NULL ) emer= models.CharField(max_length=100) mbiemer= models.CharField(max_length=100) data_e_fillimit= models.DateField() data_e_mbarimit= models.DateField( blank=True) pozicioni= models.CharField(choices=Pozicionet, max_length=100) gjinia= models.CharField(choices=Gjinia, max_length=100) numri_i_telefonit= models.CharField(blank=True, default='', max_length=10) statusi= models.CharField(choices=Status, max_length=100)
[ "vanesa.ziu@fti.edu.al" ]
vanesa.ziu@fti.edu.al
b3e42e5c8c45508dae29b2dcbc3b119b8eb9ed1f
a6d7f53090958b9bf0f4f0790522f409394f2651
/Mazzei/grammar.py
aab5a2628c539d23df1b7e5d32c3d310f3ce8c45
[]
no_license
Pep12345/TLN
31498035e815138d258941800f4daed54baba866
6b609182a6454100c75cad9d3033f3d7f1f0e79d
refs/heads/master
2023-08-22T23:26:25.292103
2021-10-28T12:44:18
2021-10-28T12:44:18
376,309,747
0
0
null
null
null
null
UTF-8
Python
false
false
1,403
py
import os from collections import defaultdict class Grammar: lexical_rules = defaultdict(set) syn_rules = defaultdict(set) def __init__(self, text_file): dir = os.path.dirname(os.path.abspath(__file__)) with open(dir + '/' + text_file, "r") as cfg: while cfg: line = cfg.readline() if line == "": break line = line.replace('| ', '|').replace(' |', '|').replace('\n', '').split('->') for body in line[1].split('|'): self.add_rule(line[0], body) def add_rule(self, head, body): if body[0] == '\'': self.lexical_rules[body.replace('\'','').lower()].add(head) else: self.syn_rules[body].add(head) #Get testa regola dato corpo def get_rules_for_word(self, word): return list(self.lexical_rules.get(word.lower()) if self.lexical_rules.__contains__(word.lower()) else []) def get_rules_for_tag(self, tag): return list(self.syn_rules.get(tag) if self.syn_rules.__contains__(tag) else []) def print(self): print("Lexical ruels:") for k, v in self.lexical_rules.items(): for v1 in v: print(v1+'->'+k) print("\n\nSyn rules") for k,v in self.syn_rules.items(): for v1 in v: print(v1 + '->' + k)
[ "giuv360@hotmail.it" ]
giuv360@hotmail.it
f7c60adba3d30aed5acc0243f3a4bef6f0d7648f
e80b42fbc5f109f3979537a980eb4ea12668579e
/modules/process/popen_write.py
e1b49c189535d593455ad0b476331bf14a19ce09
[]
no_license
iliefa/pythontries
63bc38042797a47407a0e99a0c20816a8710027b
7ee793c6a248bc98da495d5936290c476bf4d77c
refs/heads/master
2020-11-25T11:13:46.212549
2019-12-18T11:56:08
2019-12-18T11:56:08
228,633,223
0
0
null
null
null
null
UTF-8
Python
false
false
159
py
import subprocess print('write') proc = subprocess.Popen( ['cat','-'], stdin=subprocess.PIPE, ) proc.communicate('stdin: to sdtin'.encode('utf-8'))
[ "andrei.ilief@orange.com" ]
andrei.ilief@orange.com
213c7dd3cb92010cf3a3b96e688a8d02dae66651
3e0341c10981b49d15c3fb458f63de59357a821b
/venv/bin/sqlformat
2a8b330f546a7b10d3c591e83eca7feae447af9f
[]
no_license
sagarsmn331/meon-task3
555f0562c036693b8e728946e01e213d1e3bdf8a
18c2e8389ee8d2bbbe18e506ccbb6d003c4ed2cf
refs/heads/master
2022-12-02T11:54:03.125091
2020-08-18T11:28:35
2020-08-18T11:28:35
288,436,935
0
0
null
null
null
null
UTF-8
Python
false
false
234
#!/home/sagar/meon5/venv/bin/python3 # -*- coding: utf-8 -*- import re import sys from sqlparse.__main__ import main if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) sys.exit(main())
[ "sagar.innotical@gmail.com" ]
sagar.innotical@gmail.com
4f3699246dd66e71b0d500dd92e454bfe9a81cce
27cb6f34181ab317531a592036505105b43f5871
/PGL/scripts/graphs/nvidia_4_2_MatVecMul_MatVecMulCoalesced1.py
ed669c572c05dc4b18a3ac986d9066ccda8e65ec
[]
no_license
xiaoyao0512/PGL_v2
0a0b70d807ea6b5b40430f438e3f8431846a2009
605cd88813c8ec805bdb44a0aa3739d850cf3116
refs/heads/master
2023-07-15T23:47:43.959936
2021-08-13T03:27:02
2021-08-13T03:27:02
392,099,888
0
0
null
null
null
null
UTF-8
Python
false
false
38,984
py
import networkx as nx import dgl def nvidia_4_2_MatVecMul_MatVecMulCoalesced1(): NXG = nx.DiGraph() NXG.add_edge(186, 200, weight=1) NXG.add_node(186, w=1) NXG.add_node(200, w=1) NXG.add_edge(137, 139, weight=1) NXG.add_node(137, w=1) NXG.add_node(139, w=1) NXG.add_edge(56, 57, weight=1) NXG.add_node(56, w=1) NXG.add_node(57, w=1) NXG.add_edge(182, 183, weight=1) NXG.add_node(182, w=1) NXG.add_node(183, w=1) NXG.add_edge(83, 85, weight=1) NXG.add_node(83, w=1) NXG.add_node(85, w=1) NXG.add_edge(348, 349, weight=13) NXG.add_node(348, w=13) NXG.add_node(349, w=13) NXG.add_edge(34, 47, weight=9) NXG.add_node(34, w=9) NXG.add_node(47, w=9) NXG.add_edge(184, 189, weight=1) NXG.add_node(184, w=1) NXG.add_node(189, w=1) NXG.add_edge(184, 194, weight=1) NXG.add_node(184, w=1) NXG.add_node(194, w=1) NXG.add_edge(184, 268, weight=1) NXG.add_node(184, w=1) NXG.add_node(268, w=1) NXG.add_edge(184, 273, weight=14) NXG.add_node(184, w=14) NXG.add_node(273, w=14) NXG.add_edge(201, 275, weight=1) NXG.add_node(201, w=1) NXG.add_node(275, w=1) NXG.add_edge(167, 168, weight=1) NXG.add_node(167, w=1) NXG.add_node(168, w=1) NXG.add_edge(375, 376, weight=1) NXG.add_node(375, w=1) NXG.add_node(376, w=1) NXG.add_edge(149, 150, weight=1) NXG.add_node(149, w=1) NXG.add_node(150, w=1) NXG.add_edge(3, 9, weight=183) NXG.add_node(3, w=183) NXG.add_node(9, w=183) NXG.add_edge(71, 243, weight=1) NXG.add_node(71, w=1) NXG.add_node(243, w=1) NXG.add_edge(339, 340, weight=1) NXG.add_node(339, w=1) NXG.add_node(340, w=1) NXG.add_edge(42, 53, weight=1) NXG.add_node(42, w=1) NXG.add_node(53, w=1) NXG.add_edge(42, 61, weight=1) NXG.add_node(42, w=1) NXG.add_node(61, w=1) NXG.add_edge(42, 83, weight=1) NXG.add_node(42, w=1) NXG.add_node(83, w=1) NXG.add_edge(42, 226, weight=1) NXG.add_node(42, w=1) NXG.add_node(226, w=1) NXG.add_edge(42, 234, weight=1) NXG.add_node(42, w=1) NXG.add_node(234, w=1) NXG.add_edge(42, 256, weight=1) NXG.add_node(42, w=1) NXG.add_node(256, w=1) NXG.add_edge(237, 251, weight=1) NXG.add_node(237, w=1) NXG.add_node(251, w=1) NXG.add_edge(265, 266, weight=1) NXG.add_node(265, w=1) NXG.add_node(266, w=1) NXG.add_edge(265, 270, weight=1) NXG.add_node(265, w=1) NXG.add_node(270, w=1) NXG.add_edge(265, 282, weight=1) NXG.add_node(265, w=1) NXG.add_node(282, w=1) NXG.add_edge(265, 291, weight=1) NXG.add_node(265, w=1) NXG.add_node(291, w=1) NXG.add_edge(265, 293, weight=15) NXG.add_node(265, w=15) NXG.add_node(293, w=15) NXG.add_edge(174, 175, weight=1) NXG.add_node(174, w=1) NXG.add_node(175, w=1) NXG.add_edge(209, 217, weight=12) NXG.add_node(209, w=12) NXG.add_node(217, w=12) NXG.add_edge(93, 94, weight=1) NXG.add_node(93, w=1) NXG.add_node(94, w=1) NXG.add_edge(384, 388, weight=1) NXG.add_node(384, w=1) NXG.add_node(388, w=1) NXG.add_edge(204, 205, weight=1) NXG.add_node(204, w=1) NXG.add_node(205, w=1) NXG.add_edge(204, 265, weight=116) NXG.add_node(204, w=116) NXG.add_node(265, w=116) NXG.add_edge(326, 327, weight=1) NXG.add_node(326, w=1) NXG.add_node(327, w=1) NXG.add_edge(95, 101, weight=1) NXG.add_node(95, w=1) NXG.add_node(101, w=1) NXG.add_edge(38, 92, weight=75) NXG.add_node(38, w=75) NXG.add_node(92, w=75) NXG.add_edge(350, 351, weight=1) NXG.add_node(350, w=1) NXG.add_node(351, w=1) NXG.add_edge(36, 59, weight=75) NXG.add_node(36, w=75) NXG.add_node(59, w=75) NXG.add_edge(254, 255, weight=13) NXG.add_node(254, w=13) NXG.add_node(255, w=13) NXG.add_edge(153, 154, weight=1) NXG.add_node(153, w=1) NXG.add_node(154, w=1) NXG.add_edge(48, 50, weight=1) NXG.add_node(48, w=1) NXG.add_node(50, w=1) NXG.add_edge(9, 16, weight=1) NXG.add_node(9, w=1) NXG.add_node(16, w=1) NXG.add_edge(9, 21, weight=13) NXG.add_node(9, w=13) NXG.add_node(21, w=13) NXG.add_edge(347, 348, weight=1) NXG.add_node(347, w=1) NXG.add_node(348, w=1) NXG.add_edge(188, 276, weight=1) NXG.add_node(188, w=1) NXG.add_node(276, w=1) NXG.add_edge(210, 382, weight=1) NXG.add_node(210, w=1) NXG.add_node(382, w=1) NXG.add_edge(393, 395, weight=1) NXG.add_node(393, w=1) NXG.add_node(395, w=1) NXG.add_edge(28, 41, weight=13) NXG.add_node(28, w=13) NXG.add_node(41, w=13) NXG.add_edge(134, 144, weight=1) NXG.add_node(134, w=1) NXG.add_node(144, w=1) NXG.add_edge(238, 250, weight=1) NXG.add_node(238, w=1) NXG.add_node(250, w=1) NXG.add_edge(141, 163, weight=1) NXG.add_node(141, w=1) NXG.add_node(163, w=1) NXG.add_edge(363, 373, weight=1) NXG.add_node(363, w=1) NXG.add_node(373, w=1) NXG.add_edge(116, 117, weight=6) NXG.add_node(116, w=6) NXG.add_node(117, w=6) NXG.add_edge(62, 63, weight=1) NXG.add_node(62, w=1) NXG.add_node(63, w=1) NXG.add_edge(382, 390, weight=15) NXG.add_node(382, w=15) NXG.add_node(390, w=15) NXG.add_edge(271, 272, weight=1) NXG.add_node(271, w=1) NXG.add_node(272, w=1) NXG.add_edge(196, 197, weight=1) NXG.add_node(196, w=1) NXG.add_node(197, w=1) NXG.add_edge(54, 56, weight=1) NXG.add_node(54, w=1) NXG.add_node(56, w=1) NXG.add_edge(40, 55, weight=1) NXG.add_node(40, w=1) NXG.add_node(55, w=1) NXG.add_edge(40, 228, weight=1) NXG.add_node(40, w=1) NXG.add_node(228, w=1) NXG.add_edge(51, 60, weight=29) NXG.add_node(51, w=29) NXG.add_node(60, w=29) NXG.add_edge(256, 258, weight=1) NXG.add_node(256, w=1) NXG.add_node(258, w=1) NXG.add_edge(281, 308, weight=1) NXG.add_node(281, w=1) NXG.add_node(308, w=1) NXG.add_edge(307, 317, weight=1) NXG.add_node(307, w=1) NXG.add_node(317, w=1) NXG.add_edge(88, 90, weight=1) NXG.add_node(88, w=1) NXG.add_node(90, w=1) NXG.add_edge(293, 294, weight=1) NXG.add_node(293, w=1) NXG.add_node(294, w=1) NXG.add_edge(293, 298, weight=1) NXG.add_node(293, w=1) NXG.add_node(298, w=1) NXG.add_edge(293, 310, weight=1) NXG.add_node(293, w=1) NXG.add_node(310, w=1) NXG.add_edge(293, 319, weight=1) NXG.add_node(293, w=1) NXG.add_node(319, w=1) NXG.add_edge(293, 321, weight=13) NXG.add_node(293, w=13) NXG.add_node(321, w=13) NXG.add_edge(253, 254, weight=1) NXG.add_node(253, w=1) NXG.add_node(254, w=1) NXG.add_edge(30, 43, weight=9) NXG.add_node(30, w=9) NXG.add_node(43, w=9) NXG.add_edge(373, 374, weight=6) NXG.add_node(373, w=6) NXG.add_node(374, w=6) NXG.add_edge(367, 368, weight=1) NXG.add_node(367, w=1) NXG.add_node(368, w=1) NXG.add_edge(163, 190, weight=1) NXG.add_node(163, w=1) NXG.add_node(190, w=1) NXG.add_edge(345, 346, weight=28) NXG.add_node(345, w=28) NXG.add_node(346, w=28) NXG.add_edge(309, 336, weight=1) NXG.add_node(309, w=1) NXG.add_node(336, w=1) NXG.add_edge(332, 346, weight=13) NXG.add_node(332, w=13) NXG.add_node(346, w=13) NXG.add_edge(117, 130, weight=1) NXG.add_node(117, w=1) NXG.add_node(130, w=1) NXG.add_edge(378, 379, weight=1) NXG.add_node(378, w=1) NXG.add_node(379, w=1) NXG.add_edge(39, 95, weight=1) NXG.add_node(39, w=1) NXG.add_node(95, w=1) NXG.add_edge(39, 100, weight=13) NXG.add_node(39, w=13) NXG.add_node(100, w=13) NXG.add_edge(123, 129, weight=1) NXG.add_node(123, w=1) NXG.add_node(129, w=1) NXG.add_edge(261, 263, weight=1) NXG.add_node(261, w=1) NXG.add_node(263, w=1) NXG.add_edge(79, 89, weight=1) NXG.add_node(79, w=1) NXG.add_node(89, w=1) NXG.add_edge(79, 232, weight=157) NXG.add_node(79, w=157) NXG.add_node(232, w=157) NXG.add_edge(371, 372, weight=1) NXG.add_node(371, w=1) NXG.add_node(372, w=1) NXG.add_edge(19, 40, weight=19) NXG.add_node(19, w=19) NXG.add_node(40, w=19) NXG.add_edge(106, 116, weight=1) NXG.add_node(106, w=1) NXG.add_node(116, w=1) NXG.add_edge(359, 373, weight=1) NXG.add_node(359, w=1) NXG.add_node(373, w=1) NXG.add_edge(275, 289, weight=1) NXG.add_node(275, w=1) NXG.add_node(289, w=1) NXG.add_edge(368, 369, weight=1) NXG.add_node(368, w=1) NXG.add_node(369, w=1) NXG.add_edge(306, 315, weight=1) NXG.add_node(306, w=1) NXG.add_node(315, w=1) NXG.add_edge(21, 42, weight=5) NXG.add_node(21, w=5) NXG.add_node(42, w=5) NXG.add_edge(391, 392, weight=1) NXG.add_node(391, w=1) NXG.add_node(392, w=1) NXG.add_edge(317, 318, weight=18) NXG.add_node(317, w=18) NXG.add_node(318, w=18) NXG.add_edge(385, 390, weight=30) NXG.add_node(385, w=30) NXG.add_node(390, w=30) NXG.add_edge(200, 201, weight=24) NXG.add_node(200, w=24) NXG.add_node(201, w=24) NXG.add_edge(74, 243, weight=1) NXG.add_node(74, w=1) NXG.add_node(243, w=1) NXG.add_edge(130, 144, weight=1) NXG.add_node(130, w=1) NXG.add_node(144, w=1) NXG.add_edge(73, 74, weight=1) NXG.add_node(73, w=1) NXG.add_node(74, w=1) NXG.add_edge(283, 284, weight=1) NXG.add_node(283, w=1) NXG.add_node(284, w=1) NXG.add_edge(394, 396, weight=1) NXG.add_node(394, w=1) NXG.add_node(396, w=1) NXG.add_edge(92, 93, weight=1) NXG.add_node(92, w=1) NXG.add_node(93, w=1) NXG.add_edge(92, 97, weight=1) NXG.add_node(92, w=1) NXG.add_node(97, w=1) NXG.add_edge(92, 109, weight=1) NXG.add_node(92, w=1) NXG.add_node(109, w=1) NXG.add_edge(92, 118, weight=1) NXG.add_node(92, w=1) NXG.add_node(118, w=1) NXG.add_edge(92, 120, weight=15) NXG.add_node(92, w=15) NXG.add_node(120, w=15) NXG.add_edge(68, 75, weight=1) NXG.add_node(68, w=1) NXG.add_node(75, w=1) NXG.add_edge(356, 357, weight=5) NXG.add_node(356, w=5) NXG.add_node(357, w=5) NXG.add_edge(233, 235, weight=1) NXG.add_node(233, w=1) NXG.add_node(235, w=1) NXG.add_edge(233, 241, weight=1) NXG.add_node(233, w=1) NXG.add_node(241, w=1) NXG.add_edge(233, 245, weight=1) NXG.add_node(233, w=1) NXG.add_node(245, w=1) NXG.add_edge(233, 253, weight=1) NXG.add_node(233, w=1) NXG.add_node(253, w=1) NXG.add_edge(233, 255, weight=15) NXG.add_node(233, w=15) NXG.add_node(255, w=15) NXG.add_edge(55, 225, weight=1) NXG.add_node(55, w=1) NXG.add_node(225, w=1) NXG.add_edge(115, 131, weight=1) NXG.add_node(115, w=1) NXG.add_node(131, w=1) NXG.add_edge(353, 356, weight=1) NXG.add_node(353, w=1) NXG.add_node(356, w=1) NXG.add_edge(224, 233, weight=32) NXG.add_node(224, w=32) NXG.add_node(233, w=32) NXG.add_edge(166, 167, weight=1) NXG.add_node(166, w=1) NXG.add_node(167, w=1) NXG.add_edge(64, 78, weight=1) NXG.add_node(64, w=1) NXG.add_node(78, w=1) NXG.add_edge(207, 208, weight=1) NXG.add_node(207, w=1) NXG.add_node(208, w=1) NXG.add_edge(193, 195, weight=1) NXG.add_node(193, w=1) NXG.add_node(195, w=1) NXG.add_edge(234, 236, weight=1) NXG.add_node(234, w=1) NXG.add_node(236, w=1) NXG.add_edge(126, 127, weight=1) NXG.add_node(126, w=1) NXG.add_node(127, w=1) NXG.add_edge(292, 293, weight=15) NXG.add_node(292, w=15) NXG.add_node(293, w=15) NXG.add_edge(220, 222, weight=1) NXG.add_node(220, w=1) NXG.add_node(222, w=1) NXG.add_edge(220, 227, weight=1) NXG.add_node(220, w=1) NXG.add_node(227, w=1) NXG.add_edge(220, 384, weight=1) NXG.add_node(220, w=1) NXG.add_node(384, w=1) NXG.add_edge(220, 391, weight=1) NXG.add_node(220, w=1) NXG.add_node(391, w=1) NXG.add_edge(220, 393, weight=9) NXG.add_node(220, w=9) NXG.add_node(393, w=9) NXG.add_edge(135, 162, weight=1) NXG.add_node(135, w=1) NXG.add_node(162, w=1) NXG.add_edge(270, 271, weight=1) NXG.add_node(270, w=1) NXG.add_node(271, w=1) NXG.add_edge(20, 41, weight=2) NXG.add_node(20, w=2) NXG.add_node(41, w=2) NXG.add_edge(70, 242, weight=1) NXG.add_node(70, w=1) NXG.add_node(242, w=1) NXG.add_edge(180, 183, weight=1) NXG.add_node(180, w=1) NXG.add_node(183, w=1) NXG.add_edge(242, 250, weight=1) NXG.add_node(242, w=1) NXG.add_node(250, w=1) NXG.add_edge(46, 51, weight=1) NXG.add_node(46, w=1) NXG.add_node(51, w=1) NXG.add_edge(46, 88, weight=1) NXG.add_node(46, w=1) NXG.add_node(88, w=1) NXG.add_edge(46, 96, weight=1) NXG.add_node(46, w=1) NXG.add_node(96, w=1) NXG.add_edge(46, 124, weight=1) NXG.add_node(46, w=1) NXG.add_node(124, w=1) NXG.add_edge(46, 152, weight=1) NXG.add_node(46, w=1) NXG.add_node(152, w=1) NXG.add_edge(46, 180, weight=1) NXG.add_node(46, w=1) NXG.add_node(180, w=1) NXG.add_edge(46, 207, weight=1) NXG.add_node(46, w=1) NXG.add_node(207, w=1) NXG.add_edge(46, 224, weight=1) NXG.add_node(46, w=1) NXG.add_node(224, w=1) NXG.add_edge(46, 261, weight=1) NXG.add_node(46, w=1) NXG.add_node(261, w=1) NXG.add_edge(46, 269, weight=1) NXG.add_node(46, w=1) NXG.add_node(269, w=1) NXG.add_edge(46, 297, weight=1) NXG.add_node(46, w=1) NXG.add_node(297, w=1) NXG.add_edge(46, 325, weight=1) NXG.add_node(46, w=1) NXG.add_node(325, w=1) NXG.add_edge(46, 353, weight=1) NXG.add_node(46, w=1) NXG.add_node(353, w=1) NXG.add_edge(46, 380, weight=1) NXG.add_node(46, w=1) NXG.add_node(380, w=1) NXG.add_edge(304, 318, weight=10) NXG.add_node(304, w=10) NXG.add_node(318, w=10) NXG.add_edge(29, 42, weight=11) NXG.add_node(29, w=11) NXG.add_node(42, w=11) NXG.add_edge(392, 393, weight=31) NXG.add_node(392, w=31) NXG.add_node(393, w=31) NXG.add_edge(140, 141, weight=1) NXG.add_node(140, w=1) NXG.add_node(141, w=1) NXG.add_edge(301, 306, weight=1) NXG.add_node(301, w=1) NXG.add_node(306, w=1) NXG.add_edge(301, 311, weight=1) NXG.add_node(301, w=1) NXG.add_node(311, w=1) NXG.add_edge(301, 324, weight=1) NXG.add_node(301, w=1) NXG.add_node(324, w=1) NXG.add_edge(301, 329, weight=15) NXG.add_node(301, w=15) NXG.add_node(329, w=15) NXG.add_edge(343, 344, weight=1) NXG.add_node(343, w=1) NXG.add_node(344, w=1) NXG.add_edge(131, 145, weight=10) NXG.add_node(131, w=10) NXG.add_node(145, w=10) NXG.add_edge(113, 135, weight=1) NXG.add_node(113, w=1) NXG.add_node(135, w=1) NXG.add_edge(164, 191, weight=1) NXG.add_node(164, w=1) NXG.add_node(191, w=1) NXG.add_edge(89, 91, weight=28) NXG.add_node(89, w=28) NXG.add_node(91, w=28) NXG.add_edge(76, 239, weight=1) NXG.add_node(76, w=1) NXG.add_node(239, w=1) NXG.add_edge(280, 307, weight=1) NXG.add_node(280, w=1) NXG.add_node(307, w=1) NXG.add_edge(176, 177, weight=1) NXG.add_node(176, w=1) NXG.add_node(177, w=1) NXG.add_edge(176, 181, weight=1) NXG.add_node(176, w=1) NXG.add_node(181, w=1) NXG.add_edge(176, 193, weight=1) NXG.add_node(176, w=1) NXG.add_node(193, w=1) NXG.add_edge(176, 202, weight=1) NXG.add_node(176, w=1) NXG.add_node(202, w=1) NXG.add_edge(176, 204, weight=13) NXG.add_node(176, w=13) NXG.add_node(204, w=13) NXG.add_edge(346, 359, weight=1) NXG.add_node(346, w=1) NXG.add_node(359, w=1) NXG.add_edge(231, 244, weight=1) NXG.add_node(231, w=1) NXG.add_node(244, w=1) NXG.add_edge(333, 360, weight=1) NXG.add_node(333, w=1) NXG.add_node(360, w=1) NXG.add_edge(111, 112, weight=1) NXG.add_node(111, w=1) NXG.add_node(112, w=1) NXG.add_edge(241, 248, weight=1) NXG.add_node(241, w=1) NXG.add_node(248, w=1) NXG.add_edge(259, 264, weight=15) NXG.add_node(259, w=15) NXG.add_node(264, w=15) NXG.add_edge(362, 371, weight=1) NXG.add_node(362, w=1) NXG.add_node(371, w=1) NXG.add_edge(291, 292, weight=1) NXG.add_node(291, w=1) NXG.add_node(292, w=1) NXG.add_edge(128, 133, weight=1) NXG.add_node(128, w=1) NXG.add_node(133, w=1) NXG.add_edge(128, 138, weight=1) NXG.add_node(128, w=1) NXG.add_node(138, w=1) NXG.add_edge(128, 151, weight=1) NXG.add_node(128, w=1) NXG.add_node(151, w=1) NXG.add_edge(128, 156, weight=12) NXG.add_node(128, w=12) NXG.add_node(156, w=12) NXG.add_edge(189, 198, weight=1) NXG.add_node(189, w=1) NXG.add_node(198, w=1) NXG.add_edge(213, 385, weight=1) NXG.add_node(213, w=1) NXG.add_node(385, w=1) NXG.add_edge(152, 155, weight=1) NXG.add_node(152, w=1) NXG.add_node(155, w=1) NXG.add_edge(45, 87, weight=1) NXG.add_node(45, w=1) NXG.add_node(87, w=1) NXG.add_edge(45, 104, weight=1) NXG.add_node(45, w=1) NXG.add_node(104, w=1) NXG.add_edge(45, 108, weight=1) NXG.add_node(45, w=1) NXG.add_node(108, w=1) NXG.add_edge(45, 132, weight=1) NXG.add_node(45, w=1) NXG.add_node(132, w=1) NXG.add_edge(45, 136, weight=1) NXG.add_node(45, w=1) NXG.add_node(136, w=1) NXG.add_edge(45, 160, weight=1) NXG.add_node(45, w=1) NXG.add_node(160, w=1) NXG.add_edge(45, 164, weight=1) NXG.add_node(45, w=1) NXG.add_node(164, w=1) NXG.add_edge(45, 188, weight=1) NXG.add_node(45, w=1) NXG.add_node(188, w=1) NXG.add_edge(45, 192, weight=1) NXG.add_node(45, w=1) NXG.add_node(192, w=1) NXG.add_edge(45, 214, weight=1) NXG.add_node(45, w=1) NXG.add_node(214, w=1) NXG.add_edge(45, 260, weight=1) NXG.add_node(45, w=1) NXG.add_node(260, w=1) NXG.add_edge(45, 277, weight=1) NXG.add_node(45, w=1) NXG.add_node(277, w=1) NXG.add_edge(45, 281, weight=1) NXG.add_node(45, w=1) NXG.add_node(281, w=1) NXG.add_edge(45, 305, weight=1) NXG.add_node(45, w=1) NXG.add_node(305, w=1) NXG.add_edge(45, 309, weight=1) NXG.add_node(45, w=1) NXG.add_node(309, w=1) NXG.add_edge(45, 333, weight=1) NXG.add_node(45, w=1) NXG.add_node(333, w=1) NXG.add_edge(45, 337, weight=1) NXG.add_node(45, w=1) NXG.add_node(337, w=1) NXG.add_edge(45, 361, weight=1) NXG.add_node(45, w=1) NXG.add_node(361, w=1) NXG.add_edge(45, 365, weight=1) NXG.add_node(45, w=1) NXG.add_node(365, w=1) NXG.add_edge(45, 387, weight=1) NXG.add_node(45, w=1) NXG.add_node(387, w=1) NXG.add_edge(158, 172, weight=1) NXG.add_node(158, w=1) NXG.add_node(172, w=1) NXG.add_edge(170, 171, weight=1) NXG.add_node(170, w=1) NXG.add_node(171, w=1) NXG.add_edge(262, 264, weight=21) NXG.add_node(262, w=21) NXG.add_node(264, w=21) NXG.add_edge(199, 276, weight=1) NXG.add_node(199, w=1) NXG.add_node(276, w=1) NXG.add_edge(355, 356, weight=1) NXG.add_node(355, w=1) NXG.add_node(356, w=1) NXG.add_edge(211, 215, weight=1) NXG.add_node(211, w=1) NXG.add_node(215, w=1) NXG.add_edge(133, 142, weight=1) NXG.add_node(133, w=1) NXG.add_node(142, w=1) NXG.add_edge(202, 203, weight=1) NXG.add_node(202, w=1) NXG.add_node(203, w=1) NXG.add_edge(49, 50, weight=1) NXG.add_node(49, w=1) NXG.add_node(50, w=1) NXG.add_edge(66, 238, weight=1) NXG.add_node(66, w=1) NXG.add_node(238, w=1) NXG.add_edge(360, 374, weight=9) NXG.add_node(360, w=9) NXG.add_node(374, w=9) NXG.add_edge(10, 15, weight=1) NXG.add_node(10, w=1) NXG.add_node(15, w=1) NXG.add_edge(10, 22, weight=15) NXG.add_node(10, w=15) NXG.add_node(22, w=15) NXG.add_edge(169, 191, weight=1) NXG.add_node(169, w=1) NXG.add_node(191, w=1) NXG.add_edge(127, 128, weight=5) NXG.add_node(127, w=5) NXG.add_node(128, w=5) NXG.add_edge(315, 316, weight=1) NXG.add_node(315, w=1) NXG.add_node(316, w=1) NXG.add_edge(268, 274, weight=1) NXG.add_node(268, w=1) NXG.add_node(274, w=1) NXG.add_edge(269, 272, weight=1) NXG.add_node(269, w=1) NXG.add_node(272, w=1) NXG.add_edge(84, 85, weight=1) NXG.add_node(84, w=1) NXG.add_node(85, w=1) NXG.add_edge(226, 229, weight=1) NXG.add_node(226, w=1) NXG.add_node(229, w=1) NXG.add_edge(354, 355, weight=1) NXG.add_node(354, w=1) NXG.add_node(355, w=1) NXG.add_edge(41, 67, weight=1) NXG.add_node(41, w=1) NXG.add_node(67, w=1) NXG.add_edge(41, 240, weight=1) NXG.add_node(41, w=1) NXG.add_node(240, w=1) NXG.add_edge(290, 303, weight=1) NXG.add_node(290, w=1) NXG.add_node(303, w=1) NXG.add_edge(98, 99, weight=1) NXG.add_node(98, w=1) NXG.add_node(99, w=1) NXG.add_edge(320, 321, weight=2) NXG.add_node(320, w=2) NXG.add_node(321, w=2) NXG.add_edge(282, 284, weight=1) NXG.add_node(282, w=1) NXG.add_node(284, w=1) NXG.add_edge(329, 334, weight=1) NXG.add_node(329, w=1) NXG.add_node(334, w=1) NXG.add_edge(329, 339, weight=1) NXG.add_node(329, w=1) NXG.add_node(339, w=1) NXG.add_edge(329, 352, weight=1) NXG.add_node(329, w=1) NXG.add_node(352, w=1) NXG.add_edge(329, 357, weight=8) NXG.add_node(329, w=8) NXG.add_node(357, w=8) NXG.add_edge(103, 117, weight=10) NXG.add_node(103, w=10) NXG.add_node(117, w=10) NXG.add_edge(110, 111, weight=1) NXG.add_node(110, w=1) NXG.add_node(111, w=1) NXG.add_edge(342, 364, weight=1) NXG.add_node(342, w=1) NXG.add_node(364, w=1) NXG.add_edge(112, 113, weight=1) NXG.add_node(112, w=1) NXG.add_node(113, w=1) NXG.add_edge(90, 259, weight=1) NXG.add_node(90, w=1) NXG.add_node(259, w=1) NXG.add_edge(197, 280, weight=1) NXG.add_node(197, w=1) NXG.add_node(280, w=1) NXG.add_edge(214, 386, weight=1) NXG.add_node(214, w=1) NXG.add_node(386, w=1) NXG.add_edge(313, 314, weight=1) NXG.add_node(313, w=1) NXG.add_node(314, w=1) NXG.add_edge(298, 299, weight=1) NXG.add_node(298, w=1) NXG.add_node(299, w=1) NXG.add_edge(105, 114, weight=1) NXG.add_node(105, w=1) NXG.add_node(114, w=1) NXG.add_edge(337, 364, weight=1) NXG.add_node(337, w=1) NXG.add_node(364, w=1) NXG.add_edge(303, 317, weight=1) NXG.add_node(303, w=1) NXG.add_node(317, w=1) NXG.add_edge(344, 360, weight=1) NXG.add_node(344, w=1) NXG.add_node(360, w=1) NXG.add_edge(136, 163, weight=1) NXG.add_node(136, w=1) NXG.add_node(163, w=1) NXG.add_edge(335, 345, weight=1) NXG.add_node(335, w=1) NXG.add_node(345, w=1) NXG.add_edge(272, 273, weight=2) NXG.add_node(272, w=2) NXG.add_node(273, w=2) NXG.add_edge(6, 12, weight=1) NXG.add_node(6, w=1) NXG.add_node(12, w=1) NXG.add_edge(6, 13, weight=1) NXG.add_node(6, w=1) NXG.add_node(13, w=1) NXG.add_edge(6, 24, weight=13) NXG.add_node(6, w=13) NXG.add_node(24, w=13) NXG.add_edge(77, 78, weight=1) NXG.add_node(77, w=1) NXG.add_node(78, w=1) NXG.add_edge(216, 382, weight=1) NXG.add_node(216, w=1) NXG.add_node(382, w=1) NXG.add_edge(340, 341, weight=1) NXG.add_node(340, w=1) NXG.add_node(341, w=1) NXG.add_edge(341, 342, weight=1) NXG.add_node(341, w=1) NXG.add_node(342, w=1) NXG.add_edge(198, 199, weight=1) NXG.add_node(198, w=1) NXG.add_node(199, w=1) NXG.add_edge(142, 143, weight=1) NXG.add_node(142, w=1) NXG.add_node(143, w=1) NXG.add_edge(338, 340, weight=1) NXG.add_node(338, w=1) NXG.add_node(340, w=1) NXG.add_edge(151, 157, weight=1) NXG.add_node(151, w=1) NXG.add_node(157, w=1) NXG.add_edge(376, 377, weight=27) NXG.add_node(376, w=27) NXG.add_node(377, w=27) NXG.add_edge(171, 187, weight=1) NXG.add_node(171, w=1) NXG.add_node(187, w=1) NXG.add_edge(380, 381, weight=1) NXG.add_node(380, w=1) NXG.add_node(381, w=1) NXG.add_edge(35, 58, weight=14) NXG.add_node(35, w=14) NXG.add_node(58, w=14) NXG.add_edge(388, 389, weight=1) NXG.add_node(388, w=1) NXG.add_node(389, w=1) NXG.add_edge(52, 58, weight=9) NXG.add_node(52, w=9) NXG.add_node(58, w=9) NXG.add_edge(324, 330, weight=1) NXG.add_node(324, w=1) NXG.add_node(330, w=1) NXG.add_edge(318, 331, weight=1) NXG.add_node(318, w=1) NXG.add_node(331, w=1) NXG.add_edge(44, 210, weight=1) NXG.add_node(44, w=1) NXG.add_node(210, w=1) NXG.add_edge(44, 383, weight=1) NXG.add_node(44, w=1) NXG.add_node(383, w=1) NXG.add_edge(327, 328, weight=1) NXG.add_node(327, w=1) NXG.add_node(328, w=1) NXG.add_edge(147, 148, weight=5) NXG.add_node(147, w=5) NXG.add_node(148, w=5) NXG.add_edge(16, 21, weight=8) NXG.add_node(16, w=8) NXG.add_node(21, w=8) NXG.add_edge(16, 25, weight=56) NXG.add_node(16, w=56) NXG.add_node(25, w=56) NXG.add_edge(16, 52, weight=1) NXG.add_node(16, w=1) NXG.add_node(52, w=1) NXG.add_edge(168, 169, weight=1) NXG.add_node(168, w=1) NXG.add_node(169, w=1) NXG.add_edge(336, 363, weight=1) NXG.add_node(336, w=1) NXG.add_node(363, w=1) NXG.add_edge(96, 99, weight=1) NXG.add_node(96, w=1) NXG.add_node(99, w=1) NXG.add_edge(2, 8, weight=1) NXG.add_node(2, w=1) NXG.add_node(8, w=1) NXG.add_edge(2, 17, weight=1) NXG.add_node(2, w=1) NXG.add_node(17, w=1) NXG.add_edge(2, 20, weight=10) NXG.add_node(2, w=10) NXG.add_node(20, w=10) NXG.add_edge(121, 122, weight=1) NXG.add_node(121, w=1) NXG.add_node(122, w=1) NXG.add_edge(82, 84, weight=1) NXG.add_node(82, w=1) NXG.add_node(84, w=1) NXG.add_edge(82, 233, weight=11) NXG.add_node(82, w=11) NXG.add_node(233, w=11) NXG.add_edge(321, 322, weight=1) NXG.add_node(321, w=1) NXG.add_node(322, w=1) NXG.add_edge(321, 326, weight=1) NXG.add_node(321, w=1) NXG.add_node(326, w=1) NXG.add_edge(321, 338, weight=1) NXG.add_node(321, w=1) NXG.add_node(338, w=1) NXG.add_edge(321, 347, weight=1) NXG.add_node(321, w=1) NXG.add_node(347, w=1) NXG.add_edge(321, 349, weight=11) NXG.add_node(321, w=11) NXG.add_node(349, w=11) NXG.add_edge(108, 135, weight=1) NXG.add_node(108, w=1) NXG.add_node(135, w=1) NXG.add_edge(192, 280, weight=1) NXG.add_node(192, w=1) NXG.add_node(280, w=1) NXG.add_edge(31, 44, weight=13) NXG.add_node(31, w=13) NXG.add_node(44, w=13) NXG.add_edge(205, 206, weight=1) NXG.add_node(205, w=1) NXG.add_node(206, w=1) NXG.add_edge(349, 350, weight=1) NXG.add_node(349, w=1) NXG.add_node(350, w=1) NXG.add_edge(349, 354, weight=1) NXG.add_node(349, w=1) NXG.add_node(354, w=1) NXG.add_edge(349, 366, weight=1) NXG.add_node(349, w=1) NXG.add_node(366, w=1) NXG.add_edge(349, 375, weight=1) NXG.add_node(349, w=1) NXG.add_node(375, w=1) NXG.add_edge(349, 377, weight=11) NXG.add_node(349, w=11) NXG.add_node(377, w=11) NXG.add_edge(118, 119, weight=1) NXG.add_node(118, w=1) NXG.add_node(119, w=1) NXG.add_edge(154, 155, weight=1) NXG.add_node(154, w=1) NXG.add_node(155, w=1) NXG.add_edge(58, 71, weight=1) NXG.add_node(58, w=1) NXG.add_node(71, w=1) NXG.add_edge(58, 231, weight=9) NXG.add_node(58, w=9) NXG.add_node(231, w=9) NXG.add_edge(100, 105, weight=1) NXG.add_node(100, w=1) NXG.add_node(105, w=1) NXG.add_edge(100, 110, weight=1) NXG.add_node(100, w=1) NXG.add_node(110, w=1) NXG.add_edge(100, 123, weight=1) NXG.add_node(100, w=1) NXG.add_node(123, w=1) NXG.add_edge(100, 128, weight=9) NXG.add_node(100, w=9) NXG.add_node(128, w=9) NXG.add_edge(87, 259, weight=1) NXG.add_node(87, w=1) NXG.add_node(259, w=1) NXG.add_edge(221, 223, weight=1) NXG.add_node(221, w=1) NXG.add_node(223, w=1) NXG.add_edge(369, 370, weight=1) NXG.add_node(369, w=1) NXG.add_node(370, w=1) NXG.add_edge(296, 302, weight=1) NXG.add_node(296, w=1) NXG.add_node(302, w=1) NXG.add_edge(284, 285, weight=1) NXG.add_node(284, w=1) NXG.add_node(285, w=1) NXG.add_edge(97, 98, weight=1) NXG.add_node(97, w=1) NXG.add_node(98, w=1) NXG.add_edge(294, 295, weight=1) NXG.add_node(294, w=1) NXG.add_node(295, w=1) NXG.add_edge(162, 172, weight=1) NXG.add_node(162, w=1) NXG.add_node(172, w=1) NXG.add_edge(18, 19, weight=26) NXG.add_node(18, w=26) NXG.add_node(19, w=26) NXG.add_edge(18, 25, weight=8) NXG.add_node(18, w=8) NXG.add_node(25, w=8) NXG.add_edge(227, 229, weight=1) NXG.add_node(227, w=1) NXG.add_node(229, w=1) NXG.add_edge(156, 161, weight=1) NXG.add_node(156, w=1) NXG.add_node(161, w=1) NXG.add_edge(156, 166, weight=1) NXG.add_node(156, w=1) NXG.add_node(166, w=1) NXG.add_edge(156, 179, weight=1) NXG.add_node(156, w=1) NXG.add_node(179, w=1) NXG.add_edge(156, 184, weight=10) NXG.add_node(156, w=10) NXG.add_node(184, w=10) NXG.add_edge(250, 251, weight=1) NXG.add_node(250, w=1) NXG.add_node(251, w=1) NXG.add_edge(219, 220, weight=31) NXG.add_node(219, w=31) NXG.add_node(220, w=31) NXG.add_edge(86, 91, weight=13) NXG.add_node(86, w=13) NXG.add_node(91, w=13) NXG.add_edge(319, 320, weight=1) NXG.add_node(319, w=1) NXG.add_node(320, w=1) NXG.add_edge(23, 44, weight=23) NXG.add_node(23, w=23) NXG.add_node(44, w=23) NXG.add_edge(146, 147, weight=1) NXG.add_node(146, w=1) NXG.add_node(147, w=1) NXG.add_edge(57, 225, weight=1) NXG.add_node(57, w=1) NXG.add_node(225, w=1) NXG.add_edge(278, 287, weight=1) NXG.add_node(278, w=1) NXG.add_node(287, w=1) NXG.add_edge(132, 159, weight=1) NXG.add_node(132, w=1) NXG.add_node(159, w=1) NXG.add_edge(218, 219, weight=1) NXG.add_node(218, w=1) NXG.add_node(219, w=1) NXG.add_edge(215, 216, weight=1) NXG.add_node(215, w=1) NXG.add_node(216, w=1) NXG.add_edge(125, 126, weight=1) NXG.add_node(125, w=1) NXG.add_node(126, w=1) NXG.add_edge(124, 127, weight=1) NXG.add_node(124, w=1) NXG.add_node(127, w=1) NXG.add_edge(26, 47, weight=14) NXG.add_node(26, w=14) NXG.add_node(47, w=14) NXG.add_edge(299, 300, weight=1) NXG.add_node(299, w=1) NXG.add_node(300, w=1) NXG.add_edge(328, 329, weight=29) NXG.add_node(328, w=29) NXG.add_node(329, w=29) NXG.add_edge(287, 288, weight=1) NXG.add_node(287, w=1) NXG.add_node(288, w=1) NXG.add_edge(80, 81, weight=1) NXG.add_node(80, w=1) NXG.add_node(81, w=1) NXG.add_edge(60, 62, weight=1) NXG.add_node(60, w=1) NXG.add_node(62, w=1) NXG.add_edge(60, 68, weight=1) NXG.add_node(60, w=1) NXG.add_node(68, w=1) NXG.add_edge(60, 72, weight=1) NXG.add_node(60, w=1) NXG.add_node(72, w=1) NXG.add_edge(60, 80, weight=1) NXG.add_node(60, w=1) NXG.add_node(80, w=1) NXG.add_edge(60, 82, weight=8) NXG.add_node(60, w=8) NXG.add_node(82, w=8) NXG.add_edge(266, 267, weight=1) NXG.add_node(266, w=1) NXG.add_node(267, w=1) NXG.add_edge(165, 167, weight=1) NXG.add_node(165, w=1) NXG.add_node(167, w=1) NXG.add_edge(273, 278, weight=1) NXG.add_node(273, w=1) NXG.add_node(278, w=1) NXG.add_edge(273, 283, weight=1) NXG.add_node(273, w=1) NXG.add_node(283, w=1) NXG.add_edge(273, 296, weight=1) NXG.add_node(273, w=1) NXG.add_node(296, w=1) NXG.add_edge(273, 301, weight=11) NXG.add_node(273, w=11) NXG.add_node(301, w=11) NXG.add_edge(17, 20, weight=9) NXG.add_node(17, w=9) NXG.add_node(20, w=9) NXG.add_edge(17, 25, weight=49) NXG.add_node(17, w=49) NXG.add_node(25, w=49) NXG.add_edge(47, 49, weight=1) NXG.add_node(47, w=1) NXG.add_node(49, w=1) NXG.add_edge(47, 54, weight=1) NXG.add_node(47, w=1) NXG.add_node(54, w=1) NXG.add_edge(47, 211, weight=1) NXG.add_node(47, w=1) NXG.add_node(211, w=1) NXG.add_edge(47, 218, weight=1) NXG.add_node(47, w=1) NXG.add_node(218, w=1) NXG.add_edge(47, 220, weight=10) NXG.add_node(47, w=10) NXG.add_node(220, w=10) NXG.add_edge(255, 257, weight=1) NXG.add_node(255, w=1) NXG.add_node(257, w=1) NXG.add_edge(69, 77, weight=1) NXG.add_node(69, w=1) NXG.add_node(77, w=1) NXG.add_edge(314, 336, weight=1) NXG.add_node(314, w=1) NXG.add_node(336, w=1) NXG.add_edge(357, 362, weight=1) NXG.add_node(357, w=1) NXG.add_node(362, w=1) NXG.add_edge(357, 367, weight=1) NXG.add_node(357, w=1) NXG.add_node(367, w=1) NXG.add_edge(109, 111, weight=1) NXG.add_node(109, w=1) NXG.add_node(111, w=1) NXG.add_edge(235, 236, weight=1) NXG.add_node(235, w=1) NXG.add_node(236, w=1) NXG.add_edge(37, 60, weight=13) NXG.add_node(37, w=13) NXG.add_node(60, w=13) NXG.add_edge(277, 304, weight=1) NXG.add_node(277, w=1) NXG.add_node(304, w=1) NXG.add_edge(286, 308, weight=1) NXG.add_node(286, w=1) NXG.add_node(308, w=1) NXG.add_edge(246, 247, weight=1) NXG.add_node(246, w=1) NXG.add_node(247, w=1) NXG.add_edge(43, 48, weight=1) NXG.add_node(43, w=1) NXG.add_node(48, w=1) NXG.add_edge(43, 221, weight=1) NXG.add_node(43, w=1) NXG.add_node(221, w=1) NXG.add_edge(43, 394, weight=1) NXG.add_node(43, w=1) NXG.add_node(394, w=1) NXG.add_edge(114, 115, weight=1) NXG.add_node(114, w=1) NXG.add_node(115, w=1) NXG.add_edge(27, 40, weight=11) NXG.add_node(27, w=11) NXG.add_node(40, w=11) NXG.add_edge(225, 231, weight=2) NXG.add_node(225, w=2) NXG.add_node(231, w=2) NXG.add_edge(232, 237, weight=1) NXG.add_node(232, w=1) NXG.add_node(237, w=1) NXG.add_edge(232, 252, weight=8) NXG.add_node(232, w=8) NXG.add_node(252, w=8) NXG.add_edge(173, 186, weight=1) NXG.add_node(173, w=1) NXG.add_node(186, w=1) NXG.add_edge(288, 304, weight=1) NXG.add_node(288, w=1) NXG.add_node(304, w=1) NXG.add_edge(148, 149, weight=1) NXG.add_node(148, w=1) NXG.add_node(149, w=1) NXG.add_edge(148, 153, weight=1) NXG.add_node(148, w=1) NXG.add_node(153, w=1) NXG.add_edge(148, 165, weight=1) NXG.add_node(148, w=1) NXG.add_node(165, w=1) NXG.add_edge(148, 174, weight=1) NXG.add_node(148, w=1) NXG.add_node(174, w=1) NXG.add_edge(148, 176, weight=9) NXG.add_node(148, w=9) NXG.add_node(176, w=9) NXG.add_edge(160, 187, weight=1) NXG.add_node(160, w=1) NXG.add_node(187, w=1) NXG.add_edge(107, 134, weight=1) NXG.add_node(107, w=1) NXG.add_node(134, w=1) NXG.add_edge(78, 79, weight=8) NXG.add_node(78, w=8) NXG.add_node(79, w=8) NXG.add_edge(195, 196, weight=1) NXG.add_node(195, w=1) NXG.add_node(196, w=1) NXG.add_edge(257, 258, weight=1) NXG.add_node(257, w=1) NXG.add_node(258, w=1) NXG.add_edge(32, 45, weight=13) NXG.add_node(32, w=13) NXG.add_node(45, w=13) NXG.add_edge(276, 290, weight=12) NXG.add_node(276, w=12) NXG.add_node(290, w=12) NXG.add_edge(187, 201, weight=14) NXG.add_node(187, w=14) NXG.add_node(201, w=14) NXG.add_edge(212, 217, weight=12) NXG.add_node(212, w=12) NXG.add_node(217, w=12) NXG.add_edge(81, 82, weight=29) NXG.add_node(81, w=29) NXG.add_node(82, w=29) NXG.add_edge(144, 145, weight=30) NXG.add_node(144, w=30) NXG.add_node(145, w=30) NXG.add_edge(67, 239, weight=1) NXG.add_node(67, w=1) NXG.add_node(239, w=1) NXG.add_edge(203, 204, weight=15) NXG.add_node(203, w=15) NXG.add_node(204, w=15) NXG.add_edge(75, 76, weight=1) NXG.add_node(75, w=1) NXG.add_node(76, w=1) NXG.add_edge(279, 289, weight=1) NXG.add_node(279, w=1) NXG.add_node(289, w=1) NXG.add_edge(22, 43, weight=5) NXG.add_node(22, w=5) NXG.add_node(43, w=5) NXG.add_edge(331, 345, weight=1) NXG.add_node(331, w=1) NXG.add_node(345, w=1) NXG.add_edge(104, 131, weight=1) NXG.add_node(104, w=1) NXG.add_node(131, w=1) NXG.add_edge(159, 173, weight=13) NXG.add_node(159, w=13) NXG.add_node(173, w=13) NXG.add_edge(310, 312, weight=1) NXG.add_node(310, w=1) NXG.add_node(312, w=1) NXG.add_edge(191, 279, weight=1) NXG.add_node(191, w=1) NXG.add_node(279, w=1) NXG.add_edge(289, 290, weight=11) NXG.add_node(289, w=11) NXG.add_node(290, w=11) NXG.add_edge(24, 45, weight=10) NXG.add_node(24, w=10) NXG.add_node(45, w=10) NXG.add_edge(72, 73, weight=1) NXG.add_node(72, w=1) NXG.add_node(73, w=1) NXG.add_edge(102, 116, weight=1) NXG.add_node(102, w=1) NXG.add_node(116, w=1) NXG.add_edge(285, 286, weight=1) NXG.add_node(285, w=1) NXG.add_node(286, w=1) NXG.add_edge(161, 170, weight=1) NXG.add_node(161, w=1) NXG.add_node(170, w=1) NXG.add_edge(366, 368, weight=1) NXG.add_node(366, w=1) NXG.add_node(368, w=1) NXG.add_edge(352, 358, weight=1) NXG.add_node(352, w=1) NXG.add_node(358, w=1) NXG.add_edge(120, 121, weight=1) NXG.add_node(120, w=1) NXG.add_node(121, w=1) NXG.add_edge(120, 125, weight=1) NXG.add_node(120, w=1) NXG.add_node(125, w=1) NXG.add_edge(120, 137, weight=1) NXG.add_node(120, w=1) NXG.add_node(137, w=1) NXG.add_edge(120, 146, weight=1) NXG.add_node(120, w=1) NXG.add_node(146, w=1) NXG.add_edge(120, 148, weight=13) NXG.add_node(120, w=13) NXG.add_node(148, w=13) NXG.add_edge(1, 7, weight=1) NXG.add_node(1, w=1) NXG.add_node(7, w=1) NXG.add_edge(1, 18, weight=1) NXG.add_node(1, w=1) NXG.add_node(18, w=1) NXG.add_edge(1, 19, weight=14) NXG.add_node(1, w=14) NXG.add_node(19, w=14) NXG.add_edge(305, 332, weight=1) NXG.add_node(305, w=1) NXG.add_node(332, w=1) NXG.add_edge(252, 262, weight=1) NXG.add_node(252, w=1) NXG.add_node(262, w=1) NXG.add_edge(245, 246, weight=1) NXG.add_node(245, w=1) NXG.add_node(246, w=1) NXG.add_edge(322, 323, weight=1) NXG.add_node(322, w=1) NXG.add_node(323, w=1) NXG.add_edge(312, 313, weight=1) NXG.add_node(312, w=1) NXG.add_node(313, w=1) NXG.add_edge(61, 63, weight=1) NXG.add_node(61, w=1) NXG.add_node(63, w=1) NXG.add_edge(334, 343, weight=1) NXG.add_node(334, w=1) NXG.add_node(343, w=1) NXG.add_edge(172, 173, weight=29) NXG.add_node(172, w=29) NXG.add_node(173, w=29) NXG.add_edge(4, 10, weight=76) NXG.add_node(4, w=76) NXG.add_node(10, w=76) NXG.add_edge(14, 23, weight=21) NXG.add_node(14, w=21) NXG.add_node(23, w=21) NXG.add_edge(14, 25, weight=14) NXG.add_node(14, w=14) NXG.add_node(25, w=14) NXG.add_edge(155, 156, weight=24) NXG.add_node(155, w=24) NXG.add_node(156, w=24) NXG.add_edge(297, 300, weight=1) NXG.add_node(297, w=1) NXG.add_node(300, w=1) NXG.add_edge(300, 301, weight=16) NXG.add_node(300, w=16) NXG.add_node(301, w=16) NXG.add_edge(33, 46, weight=148) NXG.add_node(33, w=148) NXG.add_node(46, w=148) NXG.add_edge(325, 328, weight=1) NXG.add_node(325, w=1) NXG.add_node(328, w=1) NXG.add_edge(179, 185, weight=1) NXG.add_node(179, w=1) NXG.add_node(185, w=1) NXG.add_edge(377, 378, weight=1) NXG.add_node(377, w=1) NXG.add_node(378, w=1) NXG.add_edge(99, 100, weight=1) NXG.add_node(99, w=1) NXG.add_node(100, w=1) NXG.add_edge(308, 335, weight=1) NXG.add_node(308, w=1) NXG.add_node(335, w=1) NXG.add_edge(15, 22, weight=2) NXG.add_node(15, w=2) NXG.add_node(22, w=2) NXG.add_edge(15, 25, weight=10) NXG.add_node(15, w=10) NXG.add_node(25, w=10) NXG.add_edge(395, 396, weight=1) NXG.add_node(395, w=1) NXG.add_node(396, w=1) NXG.add_edge(5, 11, weight=1) NXG.add_node(5, w=1) NXG.add_node(11, w=1) NXG.add_edge(5, 14, weight=1) NXG.add_node(5, w=1) NXG.add_node(14, w=1) NXG.add_edge(5, 23, weight=11) NXG.add_node(5, w=11) NXG.add_node(23, w=11) NXG.add_edge(183, 184, weight=13) NXG.add_node(183, w=13) NXG.add_node(184, w=13) NXG.add_edge(119, 120, weight=13) NXG.add_node(119, w=13) NXG.add_node(120, w=13) NXG.add_edge(143, 159, weight=1) NXG.add_node(143, w=1) NXG.add_node(159, w=1) NXG.add_edge(13, 24, weight=1) NXG.add_node(13, w=1) NXG.add_node(24, w=1) NXG.add_edge(13, 25, weight=35) NXG.add_node(13, w=35) NXG.add_node(25, w=35) NXG.add_edge(248, 249, weight=1) NXG.add_node(248, w=1) NXG.add_node(249, w=1) NXG.add_edge(53, 56, weight=1) NXG.add_node(53, w=1) NXG.add_node(56, w=1) NXG.add_edge(229, 230, weight=1) NXG.add_node(229, w=1) NXG.add_node(230, w=1) NXG.add_edge(145, 158, weight=1) NXG.add_node(145, w=1) NXG.add_node(158, w=1) NXG.add_edge(311, 312, weight=1) NXG.add_node(311, w=1) NXG.add_node(312, w=1) NXG.add_edge(138, 139, weight=1) NXG.add_node(138, w=1) NXG.add_node(139, w=1) NXG.add_edge(25, 26, weight=1) NXG.add_node(25, w=1) NXG.add_node(26, w=1) NXG.add_edge(251, 252, weight=21) NXG.add_node(251, w=21) NXG.add_node(252, w=21) NXG.add_edge(181, 182, weight=1) NXG.add_node(181, w=1) NXG.add_node(182, w=1) NXG.add_edge(177, 178, weight=1) NXG.add_node(177, w=1) NXG.add_node(178, w=1) NXG.add_edge(65, 77, weight=1) NXG.add_node(65, w=1) NXG.add_node(77, w=1) NXG.add_edge(222, 223, weight=1) NXG.add_node(222, w=1) NXG.add_node(223, w=1) NXG.add_edge(175, 176, weight=28) NXG.add_node(175, w=28) NXG.add_node(176, w=28) NXG.add_edge(190, 200, weight=1) NXG.add_node(190, w=1) NXG.add_node(200, w=1) NXG.add_edge(316, 332, weight=1) NXG.add_node(316, w=1) NXG.add_node(332, w=1) NXG.add_edge(139, 140, weight=1) NXG.add_node(139, w=1) NXG.add_node(140, w=1) NXG.add_edge(59, 64, weight=1) NXG.add_node(59, w=1) NXG.add_node(64, w=1) NXG.add_edge(59, 79, weight=14) NXG.add_node(59, w=14) NXG.add_node(79, w=14) NXG.add_edge(194, 195, weight=1) NXG.add_node(194, w=1) NXG.add_node(195, w=1) g = dgl.from_networkx(NXG, edge_attrs=['weight'], node_attrs=['w']) return g
[ "xiaoyao@usc.edu" ]
xiaoyao@usc.edu
4c7f830389c9108013b3b1e13872322bea7f2a1a
dd887dc97be27c140891205ad2fabe78ab725d59
/run_tests.py
41ec83601518010e56d4d679a5dadb7f5a9cf8e9
[]
no_license
angelhof/edsger_compiler
b5be2cc00ff60cd6ca81ff9a47439d527dc027be
4b063f6693d21bbed2c06ff7a58c2457239f12e1
refs/heads/master
2021-01-19T12:15:43.953628
2017-09-27T08:53:58
2017-09-27T08:53:58
84,454,187
4
0
null
null
null
null
UTF-8
Python
false
false
2,971
py
#!/usr/bin/env python import os import sys import difflib old_way = False if(not len(sys.argv) == 2): print "Usage: python run_tests.py <file_with_test_names>" exit(1) try: test_files = open(sys.argv[1]) except: print "File with name: " + sys.argv[1] + " doesn't exist!!" exit(1) correct = 0 total_tests = 0 for test_name_newline in test_files.readlines(): test_line = test_name_newline.rstrip().split(" ") test_name = test_line[0] test_input = None if(len(test_line) > 1): test_input = test_line[1] # Compile cedsg res = os.system("python cedsg.py tests/" + test_name + " > /dev/null 2>&1") if(not res == 0): print "Compiler Error at: " + test_name # Execute test if(test_input is not None): res3 = os.system("cat tests/" + test_name + ".in | ./a.out > tests/outputs/" + test_name) else: res3 = os.system("./a.out > tests/outputs/" + test_name) if(not res3 == 0): print "Execution Error at: " + test_name if(res+res3 == 0): my_output = open("tests/outputs/"+test_name).read() expected_output = open("tests/expected_outputs/"+test_name).read() '''Debug Only: print my_output print expected_output for i,s in enumerate(difflib.ndiff(my_output, expected_output)): if s[0]==' ': continue elif s[0]=='-': print(u'Delete "{}" from position {}'.format(s[-1],i)) elif s[0]=='+': print(u'Add "{}" to position {}'.format(s[-1],i)) ''' if(my_output == expected_output): correct += 1 else: print "Wrong output for: " + test_name total_tests += 1 ''' TODO: Delete, Old way of running tests ''' if(old_way): res = os.system("python cedsg.py tests/" + test_name + " > /dev/null 2>&1") if(not res == 0): print "Compiler Error at: " + test_name res1 = os.system("llc -mtriple=\"x86_64-unknown-gnulinux\" test_asm > /dev/null 2>&1") if(not res1 == 0): print "llc Error at: " + test_name res2 = os.system("clang test_asm.s lib.a -o test_x86 > /dev/null 2>&1") if(not res2 == 0): print "Clang Error at: " + test_name if(test_input is not None): res3 = os.system("cat tests/" + test_name + ".in | ./test_x86 > tests/outputs/" + test_name) else: res3 = os.system("./test_x86 > tests/outputs/" + test_name) if(not res3 == 0): print "Execution Error at: " + test_name if(res+res1+res2+res3 == 0): my_output = open("tests/outputs/"+test_name).read() expected_output = open("tests/expected_outputs/"+test_name).read() '''Debug Only: print my_output print expected_output for i,s in enumerate(difflib.ndiff(my_output, expected_output)): if s[0]==' ': continue elif s[0]=='-': print(u'Delete "{}" from position {}'.format(s[-1],i)) elif s[0]=='+': print(u'Add "{}" to position {}'.format(s[-1],i)) ''' if(my_output == expected_output): correct += 1 else: print "Wrong output for: " + test_name total_tests += 1 print "Correct: " + str(correct) + " out of: " + str(total_tests)
[ "konstantinos.kallas@hotmail.com" ]
konstantinos.kallas@hotmail.com
ad51ec45498d2d45376a45f8d7eb8760d66fb9cc
13b64d337210fe93d367ce102375baaba768deeb
/Test5/__init__.py
5858657ab37c81080becce3f0d6b7d0f9d3404a3
[]
no_license
GummiRichy/NHS-Gashapon
91a3d8a744b682bb9f9bdcd1addc3d6a22f45bec
bbd98f4f939aed4ff1d0467f60b48d2ba56f2666
refs/heads/main
2023-02-26T14:29:25.113583
2021-02-03T21:28:42
2021-02-03T21:28:42
334,280,678
0
0
null
null
null
null
UTF-8
Python
false
false
2,746
py
from flask import Flask, request, send_from_directory, render_template, jsonify, make_response import os from hashlib import sha256 import json from random import random import requests app = Flask(__name__) prizes = ("Chocolate", "Strawberry Starburst", "Cherry Starburst", "Orange Starburst", "Lemon Starburst") probabilities = (0.4, 0.15, 0.15, 0.15, 0.15) assert sum(probabilities) == 1 assert len(prizes) == len(probabilities) GITHUB_TOKEN = "secret token here" USED_CODES_PATH = "static/used_codes.json" hashes = requests.get("https://pastebin.com/raw/DUV5ztr1").text.split("\n") hashes = [x.strip('\r') for x in hashes] #print(hashes) def save_used_codes(used_codes): #this uses github gists to save our used codes file gist_id="9099922858882e94fdb16ca3c9293dfa" content=json.dumps(used_codes, indent = 4, sort_keys=True) filename = "gashapon_used_codes" headers = {'Authorization': f'token {GITHUB_TOKEN}'} r = requests.patch('https://api.github.com/gists/' + gist_id, data=json.dumps({'files':{filename:{"content":content}}}),headers=headers) #print(r.json()) with open(USED_CODES_PATH, 'w') as f: f.write(content) def get_used_codes(): with open(USED_CODES_PATH) as f: return json.load(f) def pick_randomly(): #this number randomly picks a number from 1 to n inclusive (assuming there are n different types of prizes) according the the weighted probabilities num = random() for i in range(len(prizes)): num -= probabilities[i] if num < 0: return i + 1 print("this should never really happen") return len(prizes) + 1 @app.route("/") def home(): return render_template("index.html") @app.route("/getcode", methods = ["POST"]) def handle_code(): used_codes = get_used_codes() code = request.get_json() #print(req) #print(type(req)) if not type(code) == type(""): res = make_response(jsonify(0), 200) return res if not code.isdigit(): res = make_response(jsonify(0), 200) return res if sha256(code.encode('utf-8')).hexdigest() in hashes: if code not in used_codes.keys(): result = pick_randomly() used_codes[code] = prizes[result - 1] save_used_codes(used_codes) res = make_response(jsonify(result), 200) return res else: result = prizes.index(used_codes[code]) + 1 result = -result res = make_response(jsonify(result), 200) return res else: res = make_response(jsonify(0), 200) return res if __name__ == "__main__": app.run(host = "0.0.0.0", port = 80)
[ "noreply@github.com" ]
GummiRichy.noreply@github.com
b3c030f1768dcfc0cd596fb8f8ba97bdcca9e738
a3ae31031057f807079880486dc79a816ad864c4
/jpg2bmp/jpg2bmp.py
3893a54a63f7dc66e85213e498533ace69633eee
[]
no_license
kyumdbot/Slides-TFT_TouchShield
3325de4a2ad663ddd613fa697e6893a55fce4990
5995d3d9301e6b77f5dcf8b60c1def07f1270ae2
refs/heads/master
2020-04-23T02:06:33.325658
2019-02-18T03:55:11
2019-02-18T03:55:11
170,835,186
0
0
null
null
null
null
UTF-8
Python
false
false
237
py
from PIL import Image names = ["launch", "001", "002", "003", "004", "005", "006"] for name in names: im = Image.open(name + ".jpg").convert("RGB") im.save(name + ".bmp") print("output: " + name + ".bmp") print("Done!")
[ "kyumd001@gmail.com" ]
kyumd001@gmail.com
3602ba7107adda3c0f8537ccf5391aca5a28d5da
2dcd80d3255266a45ad788017e1e4684e9ce66ca
/ClickToEat/migrations/0011_auto_20211011_1322.py
cd0782e6550b2db162c0683c8f62cf2723920f2e
[ "MIT" ]
permissive
Lylissa/DeliveryService
6fa5bd46fce04621e4233607e4044a9312e3207b
06ad6ed701bad0e309720726b1d16183a322418d
refs/heads/master
2023-09-03T12:20:58.573472
2021-10-27T10:09:39
2021-10-27T10:09:39
null
0
0
null
null
null
null
UTF-8
Python
false
false
770
py
# Generated by Django 3.0.5 on 2021-10-11 05:22 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('ClickToEat', '0010_auto_20211003_1048'), ] operations = [ migrations.RenameField( model_name='client', old_name='client_id', new_name='id', ), migrations.RenameField( model_name='order', old_name='order_id', new_name='id', ), migrations.RenameField( model_name='rider', old_name='rider_id', new_name='id', ), migrations.RenameField( model_name='store', old_name='store_id', new_name='id', ), ]
[ "orcullomaryalissa@gmail.com" ]
orcullomaryalissa@gmail.com
af67735fcedaaa10f128901f872b2e2215dc3f1e
c2a74d1b2d21fb22bd1ad00a3b3816966b7c8368
/data/process_data_orig.py
9acf6d0afab8b49ddb92e3251129641ac8959930
[]
no_license
pragmaticDataminer/Disaster-Response-Pipelines
2c90b2758e065e9faac5aae8ee9197e2718eed47
166d2673061edacf07d56013f22f3ac069bba298
refs/heads/master
2022-10-06T14:31:59.427964
2022-09-28T07:15:15
2022-09-28T07:15:15
211,233,237
1
0
null
null
null
null
UTF-8
Python
false
false
1,197
py
import sys def load_data(messages_filepath, categories_filepath): pass def clean_data(df): pass def save_data(df, database_filename): pass def main(): if len(sys.argv) == 4: messages_filepath, categories_filepath, database_filepath = sys.argv[1:] print('Loading data...\n MESSAGES: {}\n CATEGORIES: {}' .format(messages_filepath, categories_filepath)) df = load_data(messages_filepath, categories_filepath) print('Cleaning data...') df = clean_data(df) print('Saving data...\n DATABASE: {}'.format(database_filepath)) save_data(df, database_filepath) print('Cleaned data saved to database!') else: print('Please provide the filepaths of the messages and categories '\ 'datasets as the first and second argument respectively, as '\ 'well as the filepath of the database to save the cleaned data '\ 'to as the third argument. \n\nExample: python process_data.py '\ 'disaster_messages.csv disaster_categories.csv '\ 'DisasterResponse.db') if __name__ == '__main__': main()
[ "kusumsanand@gmail.com" ]
kusumsanand@gmail.com
75dcf7551adb829e158ce95752a5a604d343bd7b
1785ce8f49b0a253a2980d37676c62dbb4955d23
/Med/maxMinMode.py
3221580d91fa8e61057687df9dfc4895445e94a1
[]
no_license
BassP97/CTCI
29aca0913f39fc24c281f9cffb255a8e4c2f0472
6ca635efd0cacb56e7a117f6636b6126ddc8ea5b
refs/heads/master
2023-04-08T17:25:58.853342
2021-04-17T22:25:20
2021-04-17T22:25:20
185,297,152
1
0
null
null
null
null
UTF-8
Python
false
false
2,088
py
""" You decide to test if your oddly-mathematical heating company is fulfilling its All-Time Max, Min, Mean and Mode Temperature Guarantee™. Write a class TempTracker with these methods: insert()—records a new temperature get_max()—returns the highest temp we've seen so far get_min()—returns the lowest temp we've seen so far get_mean()—returns the mean of all temps we've seen so far get_mode()—returns a mode of all temps we've seen so far Optimize for space and time. Favor speeding up the getter methods get_max(), get_min(), get_mean(), and get_mode() over speeding up the insert() method. get_mean() should return a float, but the rest of the getter methods can return integers. Temperatures will all be inserted as integers. We'll record our temperatures in Fahrenheit, so we can assume they'll all be in the range 0...110 If there is more than one mode, return any of the modes. """ class tempTracker(object): def __init__(self): self.max = 0 self.min = 110 self.mean = 0 self.mode = 0 self.modeCount = 0 self.itemCount = {} self.numItems = [] def insert(self, num): if num>self.max: self.max = num if num<self.min: self.min = num self.numItems.append(num) if num not in self.itemCount.keys(): self.itemCount[num] = 0 self.numItems = self.numItems+1 self.itemCount[num] = self.itemCount[num]+1 if len(self.numItems) == 1: self.mean = num self.mode = num return self.mean = ((self.mean*(self.numItems)-1)) + num)/self.numItems) if self.mode == num: self.modeCount = self.modeCount+1 if self.itemCount[num]>self.modeCount: self.mode = num self.modeCount = self.itemCount[num] return def get_max(self): return self.max def get_mean(self): return self.mean def get_min(self): return self.min def get_mode(self): return self.mode
[ "bass_p1@denison.edu" ]
bass_p1@denison.edu
5bf7a4fe55374f3b262a1fdaa91c5b8693114712
c8809d9f6738decb8033776d27286724743a2cab
/language/python/common_module/src/main_muti_process.py
473a95b712d44cfc2168f79fe0f6bd1137aa7808
[]
no_license
lansedefen/research
8e4d46dfb761575418f21c83f2953cb00a9c96e3
3f27007a7cd468d08f6c4c271fc7b09b7ddf2f28
refs/heads/master
2021-07-10T19:40:32.973719
2019-01-19T02:17:52
2019-01-19T02:17:52
115,091,316
0
1
null
null
null
null
UTF-8
Python
false
false
2,041
py
# -*- coding: utf-8 -*- from multiprocessing import Pool, Lock from time import clock import requests from create_logger import logger import extract_weibo def mycallback(x): with open('../data/data.txt', 'a+') as f: f.writelines(str(x) + "\n") def with_lock(text): lock.acquire() with open('request.log', 'a+') as logs: logs.write('request %s cost: %s\n' % (url, end_time - start_time)) lock.release() def init_lock(l): global lock lock = l def get_weibo(mid): url = "http://10.75.57.27/getdata/querydata2.php?condition=%s&mode=weibo&format=json" % (mid.strip()) #try: if 1: start_time = clock() text = requests.get(url, timeout=4).text end_time = clock() cost_time = end_time - start_time logger.debug("url:" + url + ", cost_time:" + str(cost_time)) # do sth res = extract_weibo.parse_weibo(text) #print res #with_lock(text) return text #except: # return None def muti_process_with_map(file_name): core_num = 10 data = [] obj = open(file_name, "r") for line in obj: ele = line.strip().split("\t")[1] data.append(ele) obj.close() lock = Lock() pool = Pool(core_num, initializer = init, initargs=(lock,) ) pool.map_async(get_weibo, data, callback = mycallback) pool.close() pool.join() return def muti_process_with_apply(file_name): core_num = 10 lock = Lock() pool = Pool(core_num, initializer = init_lock, initargs=(lock,) ) obj = open(file_name, "r") for line in obj: ele = line.strip().split("\t")[1] # debug single #get_weibo(ele) #pool.apply(get_weibo, (ele, )) pool.apply_async(get_weibo, (ele, ), callback = mycallback) pool.close() pool.join() return if __name__ == '__main__': e1 = clock() file_name = "../data/bb1" muti_process_with_apply(file_name) #muti_process_with_map(file_name) e2 = clock() print float(e2 - e1)
[ "920317005@qq.com" ]
920317005@qq.com
f63f670154cf8114b2a73ebb6e41031faea6b893
f830d7bbd71fcefea6dc01ab17bd54abe626c272
/tasks/auth0/utils.py
341a4b8ebc5d672827e9e195a421b1ebcd7b8f32
[]
no_license
feedyard/baseline-aws-auth-idp
bc001c023680aaad20334fdbf08ad9d8d12e0abc
384bd8f68910691dd4ded5ffb336ea001a39945e
refs/heads/master
2020-04-21T00:57:41.234319
2019-06-20T21:40:48
2019-06-20T21:40:48
169,210,282
0
0
null
null
null
null
UTF-8
Python
false
false
9,257
py
import json import urllib.request from functools import reduce from copy import copy from auth0.v3.authentication import GetToken from auth0.v3.management import Auth0 import pkg_resources resource_package = __name__ def setup_auth0(config): """configure auth0-github as the identity provider for the master OU account in AWS""" auth0 = Auth0Builder(config["idp"]) account_config = auth0.configure_sso(config['account'], config['github']) with open(config['saml_metadata_filename'], "w") as xml_file: xml_file.write(account_config['provider_xml']) def add_org_name(mapping): org_name = config['github']['github_organization'] new_mapping = copy(mapping) new_mapping['idp_role'] = f"{org_name}/{mapping['idp_role']}" return new_mapping # client_ids = map(lambda account_conf: account_conf['client']['client_id'], account_config) auth0.deploy_rules(config['project_name'], { "client_id": account_config['client']['client_id'], "saml_provider_name": config['saml_provider_name'], "roles": map(lambda role_mapping: add_org_name(role_mapping), config['roles']) }) class Auth0Builder: def __init__(self, config): self.config = config self.auth0_client = self.create_auth0_client(config) self.script_generator = RoleRuleScriptGenerator() # get auth0 management api usage token and create auth0_python Auth0 client def create_auth0_client(self, config): domain = config["domain"] token = GetToken(domain).client_credentials(config["client_id"], config["client_secret"], f"https://{domain}/api/v2/") return Auth0(domain, token['access_token']) def configure_sso(self, account, github): new_client = self.create_aws_saml_client(account['name'], account['aws_account_number']) new_provider_xml = self.__get_saml_metadata_document(self.config['domain'], new_client['client_id']) new_connection = self.create_github_connection(f"{account['name']}-connection", new_client['client_id'], github['github_client_id'], github['github_client_secret']) return {"client": new_client, "provider_xml": new_provider_xml, "connection": new_connection} def create_aws_saml_client(self, client_name, account_id): matching_clients = list(filter(lambda c: c['name'] == client_name, self.auth0_client.clients.all())) create_client_request = json.loads( pkg_resources.resource_string(resource_package, 'base-auth0-client-message.json')) create_client_request['name'] = client_name create_client_request['client_metadata'] = { "aws_account_number": account_id } if len(matching_clients) == 0: print(f"Creating new client {client_name} for account {account_id}.") return self.auth0_client.clients.create(create_client_request) else: print(f"Updating existing client {client_name}.") del (create_client_request['jwt_configuration']['secret_encoded']) return self.auth0_client.clients.update(matching_clients[0]['client_id'], create_client_request) def create_github_connection(self, connection_name, enabled_client, github_client_id, github_secret): create_connection_request = json.loads( pkg_resources.resource_string(resource_package, 'base-github-connection-message.json')) create_connection_request['name'] = connection_name create_connection_request['enabled_clients'] = [enabled_client] create_connection_request['options']['client_id'] = github_client_id create_connection_request['options']['client_secret'] = github_secret connections = list(filter(lambda c: c['name'] == connection_name, self.auth0_client.connections.all())) if len(connections) > 0: print(f"Updating connection {connection_name}") del create_connection_request['strategy'] del create_connection_request['name'] return self.auth0_client.connections.update(connections[0]['id'], create_connection_request) else: print(f"Created connection {connection_name}") return self.auth0_client.connections.create(create_connection_request) def __get_saml_metadata_document(self, auth0_host, client_id): response = urllib.request.urlopen(f"https://{auth0_host}/samlp/metadata/{client_id}") if response.status != 200: print(f"Request to SAMLP endpoint failed with {response.status} - {response.reason}") raise Exception("Failed to get SAML metadata document") else: return response.read().decode("utf-8") def deploy_rules(self, client_name, config): self.deploy_github_connection_rule(client_name) self.deploy_rule_hierarchy(client_name, config) def deploy_github_connection_rule(self, client_name): self.__deploy_or_overwrite_rule({ "name": client_name + "-github-connection", "script": pkg_resources.resource_string(resource_package, 'github_connection.js').decode("utf-8"), "stage": "login_success" }) def deploy_rule_hierarchy(self, role_hierarchy_rule_name, config): self.__deploy_or_overwrite_rule({ "name": role_hierarchy_rule_name + "-github-team-mapping-rule", "script": self.script_generator.generate_hierarchy(config), "stage": "login_success" }) def __deploy_or_overwrite_rule(self, body): rules = list(filter(lambda c: c['name'] == body['name'], self.auth0_client.rules.all())) if len(rules) == 0: print(f"Creating rule {body['name']}") self.auth0_client.rules.create(body) else: print(f"Updating rule {body['name']}") self.auth0_client.rules.update(rules[0]['id'], { "name": body['name'], "script": body['script'] }) class RoleRuleScriptGenerator: def __init__(self): pass def generate_hierarchy(self, config): return f""" function (user, context, callback) {{ var clientId = "{config['client_id']}" ; if (clientId) {{ var role = ""; var roleMapping = {self.__generate_role_map(config)}; function hasRole(idpRole, user) {{ return user.app_metadata.roles.filter(function(userRole){{ return userRole == idpRole; }}).length > 0; }} var samlProvider = "arn:aws:iam::" + context.clientMetadata.aws_account_number + ":saml-provider/{config['saml_provider_name']}"; for (var i=0; i < roleMapping.length && !role; i++) {{ if (hasRole(roleMapping[i].idpRole, user)) {{ role = roleMapping[i].awsRole(user); }} }} user.awsRole = role + "," + samlProvider; if (!user.awsRole) {{ return callback("No role could be assigned. Please have your admin check mappings between aws role and github team.", user, context); }} user.awsRoleSession = user.nickname; context.samlConfiguration.mappings = {{ 'https://aws.amazon.com/SAML/Attributes/Role': 'awsRole', 'https://aws.amazon.com/SAML/Attributes/RoleSessionName': 'awsRoleSession' }}; if (context.protocol == 'delegation') {{ context.addonConfiguration = context.addonConfiguration || {{}}; context.addonConfiguration.aws = context.addonConfiguration.aws || {{}}; context.addonConfiguration.aws.principal = samlProvider; context.addonConfiguration.aws.role = role; }} }} callback(null, user, context); }} """ def __generate_client_Id(self, config): #client_id_strings = map(lambda client_id: f"'{client_id}':true", config['client_ids']) return f'''{{ {config} }}''' def __generate_role_mapping(self, role): aws_role_function = f""" function(user) {{ return "arn:aws:iam::" + context.clientMetadata.aws_account_number + ":role/{role['aws_role']}"; }} """ return f"""{{ idpRole:"{role['idp_role']}", awsRole: {aws_role_function} }}""" def __generate_role_map(self, config): role_map = reduce(lambda acc, item: acc + ",\n" + item, map(lambda role: self.__generate_role_mapping(role), config['roles'])) if config: return f"""[ {role_map} ]""" else: return f"[]"
[ "nchenewe@thoughtworks.com" ]
nchenewe@thoughtworks.com
89b0c5be4957f6628700adfcd85a2697e9d3a3d2
fc59ba97df7d6ff6367f2f951f791e674d16b415
/frontendshop/migrations/0003_auto_20200120_1705.py
4241262316a889178ce97460fb86fef1bb93e6ac
[]
no_license
Ran-oops/mywebsPrograme
e493853d522e3df6d3d410e4384dc80dd9aba189
438973e90dc72433b85e9a428b1b402d1a8b4f41
refs/heads/master
2020-12-13T15:51:13.883472
2020-02-01T14:46:21
2020-02-01T14:46:21
234,462,993
0
0
null
null
null
null
UTF-8
Python
false
false
3,312
py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('frontendshop', '0002_auto_20200105_1324'), ] operations = [ migrations.CreateModel( name='GoodsInfo', fields=[ ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)), ('title', models.CharField(max_length=32)), ('price', models.DecimalField(max_digits=7, decimal_places=2)), ('num', models.IntegerField()), ('storename', models.CharField(max_length=50)), ('description', models.TextField()), ('picname', models.CharField(max_length=255)), ('state', models.IntegerField()), ('clicknum', models.IntegerField()), ('addtime', models.DateTimeField()), ], ), migrations.CreateModel( name='GoodsType', fields=[ ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)), ('name', models.CharField(max_length=32)), ], ), migrations.CreateModel( name='GuestInfo', fields=[ ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)), ('name', models.CharField(max_length=100)), ('phonenumber', models.CharField(max_length=11)), ('password', models.CharField(max_length=36)), ('email', models.CharField(max_length=50)), ('sex', models.IntegerField()), ('address', models.CharField(max_length=255)), ('guestpic', models.CharField(max_length=50)), ], ), migrations.CreateModel( name='OneTypeGoodsOrder', fields=[ ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)), ('addtime', models.DateTimeField()), ('consigneename', models.CharField(max_length=32)), ('consigneetel', models.CharField(max_length=11)), ('consigneeaddress', models.CharField(max_length=50)), ('consigneecode', models.CharField(max_length=6)), ('goodsnum', models.IntegerField()), ('orderstatus', models.IntegerField()), ('goodsinfo', models.OneToOneField(to='frontendshop.GoodsInfo')), ('guestinfo', models.ForeignKey(to='frontendshop.GuestInfo')), ], ), migrations.DeleteModel( name='EVERY_ORDER', ), migrations.DeleteModel( name='GET_GOODS_ADDRESS', ), migrations.DeleteModel( name='GOODS_INFO', ), migrations.DeleteModel( name='GUEST_INFO', ), migrations.DeleteModel( name='ORDER_DETAIL', ), migrations.AddField( model_name='goodsinfo', name='goodstype', field=models.ForeignKey(to='frontendshop.GoodsType'), ), ]
[ "3460466167@qq.com" ]
3460466167@qq.com
546ac8c35f7d6abeb75985fa4d4c1e31ee9dc4ba
f8f24c63c0681111e4f286b1efbb7ed2153d1baf
/python_research/experiments/EUROMICRO2018/trt_playground/uff_engine.py
ba62bbc80bce144af8e35237157df8e10a96b0f8
[ "MIT" ]
permissive
myychal/hypernet
1deb543028169882ae731c7621e5b481e82ef48d
778e9c1a2f27ab1c664bb6d8ea49c65d0c7bdade
refs/heads/master
2020-04-02T13:50:11.812455
2018-09-19T13:19:46
2018-09-19T13:19:46
154,499,346
0
0
MIT
2018-10-24T12:42:59
2018-10-24T12:42:59
null
UTF-8
Python
false
false
7,310
py
import os from typing import Tuple import numpy as np import tensorrt as trt import uff from keras.models import load_model from tensorrt.parsers import uffparser from experiments.EUROMICRO2018.trt_playground import calibration_helpers def create_float_engine(input_shape: Tuple, model_path: str): """ Creates engine from given frozen model and saves it to disk :param input_shape: shape of input data :param model_path: path to saved model :return: engine """ assert os.path.exists(model_path) model = load_model(os.path.join(model_path, 'model.h5')) output_layer_name = model.output.name.split(':')[0] print(output_layer_name) if output_layer_name != 'output_1/Softmax': output_layer_name = 'output_1/Softmax' input_layer_name = model.input.name.split(':')[0] if input_layer_name != 'input0_1': input_layer_name = 'input0_1' print(input_layer_name) image_shape = input_shape image_shape = (image_shape[0], image_shape[2], image_shape[1]) print("Image shape:", image_shape) G_LOGGER = trt.infer.ConsoleLogger(trt.infer.LogSeverity.INFO) PATH = os.path.join(model_path, 'model.engine') # Load your newly created Tensorflow frozen model and convert it to UFF uff_model = uff.from_tensorflow_frozen_model(PATH.replace(".engine", ".pb"), [output_layer_name]) # Create a UFF parser to parse the UFF file created from your TF Frozen model parser = uffparser.create_uff_parser() parser.register_input(input_layer_name, image_shape, 0) parser.register_output(output_layer_name) # Build your TensorRT inference engine # This step performs (1) Tensor fusion (2) Reduced precision # (3) Target autotuning (4) Tensor memory management engine = trt.utils.uff_to_trt_engine(G_LOGGER, uff_model, parser, 1, #batch size 1<<20, trt.infer.DataType.FLOAT) parser.destroy() return engine def create_int_engine(calibration_data: np.ndarray, model_path: str): """ Creates engine from given frozen model and saves it to disk :param calibration_data: data used for calibration :param model_path: path to saved model :return: engine """ model = load_model(os.path.join(model_path, 'model.h5')) input_layers = [model.input.name.split(':')[0]] output_layers = [model.output.name.split(':')[0]] if input_layers[0] != 'input0_1': input_layers[0] = 'input0_1' if output_layers[0] != 'output_0_1/Softmax': output_layers[0] = 'output_0_1/Softmax' # Load your newly created Tensorflow frozen model and convert it to UFF uff_model = uff.from_tensorflow_frozen_model(os.path.join(model_path, 'model.pb'), output_layers) calibration_files = calibration_data data_size = calibration_data.shape[0] sample_shape = calibration_data[0].shape # Process 5 images at a time for calibration # This batch size can be different from MaxBatchSize (1 in this example) batchstream = calibration_helpers.ImageBatchStream(data_size, calibration_files) int8_calibrator = calibration_helpers.PythonEntropyCalibrator(input_layers, batchstream) # Easy to use TensorRT lite package # engine = trt.lite.Engine(framework="c1", # deployfile=MODEL_DIR + "fcn8s.prototxt", # modelfile=MODEL_DIR + "fcn8s.caffemodel", # max_batch_size=1, # max_workspace_size=(256 << 20), # input_nodes={"data": (CHANNEL, HEIGHT, WIDTH)}, # output_nodes=["score"], # preprocessors={"data": sub_mean_chw}, # postprocessors={"score": color_map}, # data_type=trt.infer.DataType.INT8, # calibrator=int8_calibrator, # logger_severity=trt.infer.LogSeverity.INFO) engine = trt.lite.Engine(framework='tf', path=os.path.join(model_path, 'model.pb'), # stream=uff_model, max_batch_size=100, max_workspace_size=(256 << 20), input_nodes={input_layers[0]: sample_shape}, output_nodes=output_layers, data_type=trt.infer.DataType.FLOAT, calibrator=int8_calibrator, logger_severity=trt.infer.LogSeverity.INFO, preprocessors=None, postprocessors=None) return engine def create_int_engine2(calibration_data: np.ndarray, model_path: str): """ Creates engine from given frozen model and saves it to disk :param input_shape: shape of input data :param model_path: path to saved model :return: engine """ assert os.path.exists(model_path) model = load_model(os.path.join(model_path, 'model.h5')) input_layers = [model.input.name.split(':')[0]] output_layers = [model.output.name.split(':')[0]] G_LOGGER = trt.infer.ConsoleLogger(trt.infer.LogSeverity.INFO) PATH = os.path.join(model_path, 'model.engine') # Load your newly created Tensorflow frozen model and convert it to UFF uff_model = uff.from_tensorflow_frozen_model(PATH.replace(".engine", ".pb"), output_layers) calibration_files = calibration_data data_size = calibration_data.shape[0] sample_shape = calibration_data[0].shape # Process 5 images at a time for calibration # This batch size can be different from MaxBatchSize (1 in this example) batchstream = calibration_helpers.ImageBatchStream(data_size, calibration_files) int8_calibrator = calibration_helpers.PythonEntropyCalibrator(input_layers, batchstream) # Create a UFF parser to parse the UFF file created from your TF Frozen model parser = uffparser.create_uff_parser() parser.register_input(input_layers[0], sample_shape, 0) parser.register_output(output_layers[0]) # Build your TensorRT inference engine # This step performs (1) Tensor fusion (2) Reduced precision # (3) Target autotuning (4) Tensor memory management engine = trt.utils.uff_to_trt_engine(G_LOGGER, uff_model, parser, 8, #batch size 1<<20, trt.infer.DataType.INT8, calibrator=int8_calibrator) parser.destroy() return engine def serialize_engine(engine, output_path: str): """ Serializes engine to store it on disk :param engine: engine to serialize :param output_path: path to save the engine :return: None """ assert os.path.exists(output_path) trt.utils.write_engine_to_file(output_path, engine.serialize()) print("Model serialized at:", output_path) def load_engine(): pass
[ "mantoniak@kplabs.pl" ]
mantoniak@kplabs.pl
4d665bbec6510b1bf755a90b371ba782b8f5fac0
f8bdc46409c9f5eaf3d85ef157260589462d941a
/jsk_apc2016_common/setup.py
3aac7e2ddea565c92947b1ccbddc4cfb3a5d1251
[ "MIT", "BSD-3-Clause" ]
permissive
start-jsk/jsk_apc
2e268f8b65e9d7f4f9cc4416dc8383fd0a7b9750
c4e349f45ef38457dc774e33f6902acf1a1540a6
refs/heads/master
2023-09-05T09:06:24.855510
2023-09-01T17:10:12
2023-09-01T17:10:12
25,620,908
36
25
NOASSERTION
2023-09-01T17:10:14
2014-10-23T05:28:31
Common Lisp
UTF-8
Python
false
false
232
py
#!/usr/bin/env python from distutils.core import setup from catkin_pkg.python_setup import generate_distutils_setup d = generate_distutils_setup( packages=['jsk_apc2016_common'], package_dir={'': 'python'}, ) setup(**d)
[ "www.kentaro.wada@gmail.com" ]
www.kentaro.wada@gmail.com
2715994ac90bdf445eb8b750a94410e7d0f06546
b9e12a582bb5452f7f1b9988e8f5d4dcf96e0406
/mongodb.py
a360c79eb0838f3e60a0d5753a57033909db0d62
[]
no_license
DavidJGG/cntGKE
392f6ebec422a2da0cacc285c6c814a593b40b7d
2807f4065c82b6b951bcaad10061e6622a3aa33d
refs/heads/master
2022-11-15T09:57:30.158365
2020-07-05T14:14:55
2020-07-05T14:14:55
null
0
0
null
null
null
null
UTF-8
Python
false
false
1,268
py
import pymongo from pymongo import MongoClient import redis print("\n---------------- MONGO ------------------\n") con=MongoClient('35.194.18.116',27017) try: db=con.proyecto2 #db.casos.drop() #db.casos.delete_many({"name":"LUCHO"}) print("Elementos: "+str(db.casos.count())) #for x in db.casos.find(): #print(x) except Exception as e: print(e) finally: con.close() #db.tabla1.insert({"name3":"tutorials point3"}) #db.tabla1.insert({"name4":"tutorials point4"}) #db.tabla1.insert({"name5":"tutorials point5"}) #db.tabla1.insert({"name6":"tutorials point6"}) #db.tabla1.insert({"name7":"tutorials point7"}) #db.tabla1.insert({"name8":"tutorials point8"}) #r = redis.StrictRedis(host='34.70.196.45', port=6379, db=0) #r.hset("llave", "campo1", "valor 1") print("---------------- REDIS ------------------\n") r = redis.Redis(host='35.194.18.116', port=6379) try: #r.delete("s") #r.rpush("proyecto2",'{"Nombre" : "Prueba22", "Departamento" : "San marcos", "Edad" : 37, "Forma de contagio" : "Comunitario", "Estado" : "Muerto"}') print("Elementos: "+str(r.llen("proyecto2"))) rango=r.lrange('proyecto2', 0, -1) #for x in rango: #print(x) except Exception as e: print(e) finally: r.close()
[ "jonathangmz79@hotmail.com" ]
jonathangmz79@hotmail.com
d185abfa1bcbf71f66108fd4e5874e522bf64535
c840867a4fd6a462936905c585fa0bd919fb4e8c
/assignments/assign4/FractionalKnapsack/parser.py
8a230cf6b79085a545c5aea96a047708702290d4
[ "MIT" ]
permissive
dgisolfi/Algorithms
0a0084edd02602f8f1015a64a7c9875b15a0bbdf
78584cc2b423d2dda8dd2fd6f39d33f85ab43fbe
refs/heads/master
2020-04-17T05:09:00.128893
2019-05-16T23:40:31
2019-05-16T23:40:31
166,265,240
0
0
null
null
null
null
UTF-8
Python
false
false
2,149
py
#!/usr/bin/env python3 # 2019-5-5 import re import sys from .spice import Spice from .knapsack import Knapsack from .LinkedList import LinkedList class Parser: def __init__(self, filename): self.filename = filename self.__commands = [] self.__knapsacks = [] self.__spices = LinkedList() self.parse() ''' Properties ''' @property def commands(self): return self.__commands @property def knapsacks(self): return self.__knapsacks @knapsacks.setter def knapsacks(self, knapsacks): self.__knapsacks = knapsacks @property def spices(self): return self.__spices @spices.setter def spices(self, spices): self.__spices = spices ''' Methods ''' def getCmds(self, filename): try: file = open(filename, 'r') commands = file.readlines() file.close() return commands except Exception as e: print(f'Error: {e}') def removeExtraSyntax(self): self.__commands = [re.sub(r'\n', '', line) for line in self.__commands] self.__commands = [re.sub(r'^--.*$', '', line) for line in self.__commands] def parse(self): # Get all commands from the file self.__commands = self.getCmds(self.filename) # Remove the comments and line breaks from the commands self.removeExtraSyntax() # parse all spices and knapsacks for cmd in self.commands: if re.match(r'^spice.*', cmd): cmd = cmd.replace('spice ', '') attributes = re.sub(r'\s+', '', cmd).split(';') name = attributes[0].split('=')[1] price = attributes[1].split('=')[1] quantity = attributes[2].split('=')[1] self.spices.append(Spice(name, price, quantity)) if re.match(r'^knapsack.*', cmd): cmd = cmd.replace('knapsack', '').replace(';', '') capacity = cmd.split('=')[1] self.knapsacks.append(Knapsack(capacity))
[ "daniel.gisolfi1@marist.edu" ]
daniel.gisolfi1@marist.edu
0f4416de8893caab062c43b9376c5c5b35a3203f
470631039da2cfa018192983f678278d63e1b2a7
/4-2-escape-pods.py
be686fda22404c030326a000a980763bd0cbe9a0
[]
no_license
EkanshdeepGupta/google-foobar
69e19cccf692ae603340072eaab671c23fd9327f
802901db45988382181e8081a2d78ec02bfc0960
refs/heads/master
2022-09-22T11:18:19.391988
2020-05-30T14:22:59
2020-05-30T14:22:59
268,094,372
0
0
null
null
null
null
UTF-8
Python
false
false
1,461
py
def BFS(path, s, t, parent): visited =[False]*len(path[0]) queue=[] queue.append(s) visited[s] = True while queue: u = queue.pop(0) for nbrIndex in range(len(path[u])): if path[u][nbrIndex] > 0 and not visited[nbrIndex]: queue.append(nbrIndex) visited[nbrIndex] = True parent[nbrIndex] = u return visited[t] # Classic implementation of Ford-Fulkerson algorithm def solution(entrances, exits, path): max_flow = 0 augmentPathExists=True while augmentPathExists: augmentPathExists=False for source in entrances: for sink in exits: parent = [-1]*(len(path[0])) if BFS(path, source, sink, parent): augmentPathExists = True path_flow = float("inf") s = sink while(s != source): path_flow = min(path_flow, path[parent[s]][s]) s = parent[s] max_flow += path_flow # Update residual capacities of the edges and reverse edges along the path v = sink while(v != source): u = parent[v] path[u][v] -= path_flow path[v][u] += path_flow v = parent[v] return max_flow
[ "ekanshdeep_gupta@yahoo.co.in" ]
ekanshdeep_gupta@yahoo.co.in
372255fa07e12313944b56ff6dca3baa09d97714
15fb62305a2fa0146cc84b289642cc01a8407aab
/Python/237-deleteLinkedList.py
a509709d6ca7443c76ae14bac91de99d26e78a8d
[]
no_license
geniousisme/leetCode
ec9bc91864cbe7520b085bdab0db67539d3627bd
6e12d67e4ab2d197d588b65c1ddb1f9c52a7e047
refs/heads/master
2016-09-09T23:34:03.522079
2015-09-23T16:15:05
2015-09-23T16:15:05
32,052,408
1
0
null
null
null
null
UTF-8
Python
false
false
783
py
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: # @param {ListNode} node # @return {void} Do not return anything, modify node in-place instead. def deleteNode(self, node): node.val = node.next.val node.next = node.next.next def print_llst(self, head): llst = "" while head: llst += str(head.val) if head.next: llst += '->' head = head.next print llst if __name__ == '__main__': s = Solution() test = ListNode(1) test.next = ListNode(2) test.next.next = ListNode(3) test.next.next.next = ListNode(4) s.deleteNode(test) s.print_llst(test)
[ "chia-hao.hsu@aiesec.net" ]
chia-hao.hsu@aiesec.net
f1f1c51a67a97b2c36b3b5facdae527b7e51386c
41d9b92ef2a74a4ba05d27ffbe3beb87884c4ce7
/supervised_learning/0x01-classification/9-neural_network.py
68ab716d15f8e3f5da3364211cc615f26a5956e8
[]
no_license
JosephK89/holbertonschool-machine_learning
3f96d886c61d8de99a23e4348fb045b9c930740e
aa5c500f7d8ebeec951f9ab5ec017cae64007c25
refs/heads/main
2023-08-14T18:42:53.481354
2021-10-10T19:53:40
2021-10-10T19:53:40
386,248,140
0
0
null
null
null
null
UTF-8
Python
false
false
1,248
py
#!/usr/bin/env python3 """module for neural network""" import numpy as np class NeuralNetwork: """NeuralNetwork Class""" def __init__(self, nx, nodes): """Data Initialization""" if type(nx) != int: raise TypeError("nx must be an integer") if nx < 1: raise ValueError("nx must be a positive integer") if type(nodes) != int: raise TypeError("nodes must be an integer") if nodes < 1: raise ValueError("nodes must be a positive integer") self.__W1 = np.random.randn(nodes, nx) self.__b1 = np.zeros((nodes, 1)) self.__A1 = 0 self.__W2 = np.random.randn(1, nodes) self.__b2 = 0 self.__A2 = 0 @property def W1(self): """Getter for W1""" return self.__W1 @property def b1(self): """Getter for b1""" return self.__b1 @property def A1(self): """Getter for A1""" return self.__A1 @property def W2(self): """Getter for W2""" return self.__W2 @property def b2(self): """Getter for b2""" return self.__b2 @property def A2(self): """Getter for A2""" return self.__A2
[ "josephkamel262@gmail.com" ]
josephkamel262@gmail.com
90832494883d287bf9e2722eae730348b3b733ae
a2910b1f8393dc016e254f766ee134619fe8866b
/restfulpy/marshalling.py
947d7e92dc2b7b6881a6180513f69453e5d82253
[]
no_license
mehdikiaee/restfulpy
2aee1c325f6f15d1165184a32b316efb911d7994
b1fcc08a1d1a098e915c89db90293d4e787e7411
refs/heads/master
2020-06-12T03:35:23.533919
2016-12-05T09:38:19
2016-12-05T09:38:19
75,609,025
0
0
null
2016-12-05T09:24:50
2016-12-05T09:24:49
null
UTF-8
Python
false
false
822
py
import functools from sqlalchemy.orm import Query def _serialize(obj, pagination=False, filtering=False, sorting=False, type_=None): if isinstance(obj, Query): if not type_: raise ValueError('The `model_class` keyword argument is not provided') if filtering: obj = type_.filter_by_request(obj) if sorting: obj = type_.sort_by_request(obj) if pagination: obj = type_.paginate_by_request(obj) obj = [o.to_dict() for o in obj] return obj def jsonify(*a, **options): def decorator(func): @functools.wraps(func) def wrapper(*args, **kwargs): return _serialize(func(*args, **kwargs), **options) return wrapper return decorator(a[0]) if a and callable(a[0]) else decorator
[ "vahid.mardani@gmail.com" ]
vahid.mardani@gmail.com
529ae2e99c3ada7a4b9aaab74da53c0529ad3b1c
9743d5fd24822f79c156ad112229e25adb9ed6f6
/xai/brain/wordbase/prepositions/_absents.py
10302eb756514b03c8400541c8238bea1ae518b9
[ "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
252
py
from xai.brain.wordbase.prepositions._absent import _ABSENT #calss header class _ABSENTS(_ABSENT, ): def __init__(self,): _ABSENT.__init__(self) self.name = "ABSENTS" self.specie = 'prepositions' self.basic = "absent" self.jsondata = {}
[ "xingwang1991@gmail.com" ]
xingwang1991@gmail.com
1d88378508eea50ef6f6738d2e96906457b2a852
b7b2f80ab5e1ee0ea028576e3014b62b8d3a8d7e
/pyedit/pyedit-027/pyedlib/pedbuffs.py
cd408dd6c5c83c792e2b6e3b671c66451e8e1325
[]
no_license
pglen/pgpygtk
4d1405478a714f003984cf3e3db04ff1f767470b
33f58010e304f1a312f2356de453ecedb7aa21ef
refs/heads/master
2021-01-22T01:18:52.238415
2019-01-01T01:37:24
2019-01-01T01:37:24
102,215,955
0
0
null
null
null
null
UTF-8
Python
false
false
6,130
py
#!/usr/bin/env python # Action Handler for buffers import re, string, gtk, glib, gobject import peddoc, pedync, pedconfig from pedutil import * # ------------------------------------------------------------------------- def buffers(self, self2): head = "pyedit: buffers" dialog = gtk.Dialog(head, None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) dialog.set_default_response(gtk.RESPONSE_ACCEPT) dialog.set_icon_from_file(get_img_path("pyedit_sub.png")) self.dialog = dialog xx, yy = self2.mained.window.get_size() dialog.set_default_size(3*xx/4, yy/2) dialog.treestore = None dialog.tree = create_tree(self, dialog) dialog.tree.set_headers_visible(False) dialog.tree.connect("cursor-changed", tree_sel_row, dialog, self2) dialog.tree.connect("key-press-event", area_key, dialog) dialog.tree.connect("key-release-event", area_key, dialog) stree = gtk.ScrolledWindow() stree.add(dialog.tree) frame = gtk.Frame() frame.set_shadow_type(gtk.SHADOW_ETCHED_IN) frame.add(stree) #dialog.vbox.set_spacing(8) dialog.vbox.pack_start(frame) blist = []; was = -1 nn2 = self2.notebook.get_current_page() vcurr2 = self2.notebook.get_nth_page(nn2) cc = self2.notebook.get_n_pages() for mm in range(cc): vcurr = self2.notebook.get_nth_page(mm) if was == -1 and vcurr == vcurr2: was = mm blist.append(vcurr.area.fname) update_treestore(dialog, dialog, blist, was) dialog.show_all() response = dialog.run() dialog.destroy() if response != gtk.RESPONSE_ACCEPT: return cc = self2.notebook.get_n_pages() if cc == 0: return for mm in range(cc): vcurr = self2.notebook.get_nth_page(mm) if vcurr.area.fname == dialog.res: self2.notebook.set_current_page(mm) nn2 = self2.notebook.get_current_page() vcurr2 = self2.notebook.get_nth_page(nn2) self2.mained.window.set_focus(vcurr2.vbox.area) self2.mained.window.show_all() break # ------------------------------------------------------------------------ def area_key(area, event, dialog): if event.type == gtk.gdk.KEY_PRESS: if event.keyval == gtk.keysyms.Escape: #print "Esc" dialog.response(gtk.RESPONSE_REJECT) if event.type == gtk.gdk.KEY_PRESS: if event.keyval == gtk.keysyms.Return: #print "Ret" dialog.response(gtk.RESPONSE_ACCEPT) if event.keyval == gtk.keysyms.Alt_L or \ event.keyval == gtk.keysyms.Alt_R: area.alt = True; if event.keyval == gtk.keysyms.x or \ event.keyval == gtk.keysyms.X: if area.alt: dialog.response(gtk.RESPONSE_REJECT) elif event.type == gtk.gdk.KEY_RELEASE: if event.keyval == gtk.keysyms.Alt_L or \ event.keyval == gtk.keysyms.Alt_R: area.alt = False; # ------------------------------------------------------------------------ def tree_sel_row(xtree, dialog, self2): sel = xtree.get_selection() xmodel, xiter = sel.get_selected_rows() # In muti selection, only process first for aa in xiter: xstr = xmodel.get_value(xmodel.get_iter(aa), 0) #print "Selected:", xstr dialog.res = xstr break # Tree handlers def start_tree(self, win2): if not win2.treestore: win2.treestore = gtk.TreeStore(str) # Delete previous contents try: while True: root = win2.treestore.get_iter_first() win2.treestore.remove(root) except: #print sys.exc_info() pass piter = win2.treestore.append(None, ["Searching .."]) win2.treestore.append(piter, ["None .."]) # ------------------------------------------------------------------------- def create_tree(self, win2, match = False, text = None): start_tree(self, win2) # create the TreeView using treestore tv = gtk.TreeView(win2.treestore) tv.set_enable_search(True) # create a CellRendererText to render the data cell = gtk.CellRendererText() # create the TreeViewColumn to display the data #tvcolumn = gtk.TreeViewColumn("Matches for '" + match + "'") tvcolumn = gtk.TreeViewColumn() # add the cell to the tvcolumn and allow it to expand tvcolumn.pack_start(cell, True) # set the cell "text" attribute to column 0 - retrieve text # from that column in treestore tvcolumn.add_attribute(cell, 'text', 0) # add tvcolumn to treeview tv.append_column(tvcolumn) return tv def update_treestore(self, win2, text, was): #print "was", was # Delete previous contents try: while True: root = win2.treestore.get_iter_first() win2.treestore.remove(root) except: pass #print sys.exc_info() if not text: win2.treestore.append(None, ["No Match",]) return cnt = 0; piter2 = None; next = False try: for line in text: piter = win2.treestore.append(None, [cut_lead_space(line)]) if next: next = False; piter2 = piter if cnt == was - 1: next = True cnt += 1 except: pass #print sys.exc_info() if piter2: win2.tree.set_cursor(win2.treestore.get_path(piter2)) else: root = win2.treestore.get_iter_first() win2.tree.set_cursor(win2.treestore.get_path(root))
[ "peterglen99@gmail.com" ]
peterglen99@gmail.com
64bb1e9f5015156188091feabf5221c0a4a41fd5
a73a18a2d0cfe04200cf2cac21c62a32c9d0cd6b
/amberbot.py
0482fea5721de46eae68635d01dbb0fa5e396781
[ "MIT" ]
permissive
rodincode/python
bc82e53c51edbd19ba608f6a060f2e96e2e3fbcc
5bcc53b6103e53b37a3e40635502cbca53fec43e
refs/heads/main
2023-03-21T03:25:42.380571
2021-03-14T12:14:57
2021-03-14T12:14:57
335,714,051
1
0
null
null
null
null
UTF-8
Python
false
false
5,604
py
'''from googlesearch import search import requests from bs4 import BeautifulSoup import random import pyttsx3 import pyaudio import speech_recognition as sr def speak(command): engine = pyttsx3.init() engine.say(command) engine.runAndWait() def speech_to_text(): r = sr.Recognizer() with sr.Microphone() as source: r.adjust_for_ambient_noise(source, duration = 0.2) audio = r.listen(source) try: query = r.recognize_google(audio) query = query.lower() print("Did you say: ",query) except Exception as e: speak("Sorry, I can't understand.... ") return "no info" return query speak("Hello, Maam. I am Don Jr. at your service. What can I do for you? ") query = speech_to_text() if "search" in query: speak("What do you wan to search?") query = input("What do you want to search::")+"wikipedia" links = [] for i in search(query,tld='co.in',num=10, stop=10): links.append(i) print(links) #random_link = random.choice(links) #print(random_link) random_link = links[0] response = requests.get(random_link) #print(response.text) soup = BeautifulSoup(response.text, 'html.parser') for para in soup.find_all('p'): speak(para.text) print(para.text) elif "Youtube" in query: ''' # python + SQLITE # WEBCRAWLER import sqlite3 import requests from bs4 import BeautifulSoup import re # important commands of SQL # # 1. SELECT : select data from a single table # 2. ORDER BY : sorting the data # 3. DISTINCT : finding unique rows from the table # 4. WHERE: filter rows of a result # 5. INSERT: insert rows into a table # 6. UPDATE: update existing rows # 7. DELETE: Delete rows # 8. REPLACE: insert a new row or replace the existing one ## Example:: ## SELECT * FROM Students # this command will select all values from a table called # students. ## SELECT rollno,subject FROM Students WHERE subject="Maths" #this will select all the students with their roll no # who took mathematics as a subject ## INSERT INTO students (name, roll_no,subjects,class) # VALUES ("Mike",45,"Maths",'VII-D') # this will insert values of student mike in a table called # students in their respective columns. ## Make/connect to a database db = sqlite3.connect('crawl.db') cursor = db.cursor() cursor.execute("CREATE TABLE IF NOT EXISTS websites (url,title,canonical,content)") url = input("Enter a url:: ") if len(url)<1: url = "https://www.youtube.com" def get_info(url): if 'www' in url: name= re.findall('ht.*://www\.(.*?)\.',url) name= name[0].capitalize() return name else: name = re.findall('ht.*://(.*?)\.',url) name = name[0].capitalize() return name webname = get_info(url) print(webname) urls = [] urls.append(url) def extract_content(soup): try: title = soup.title.string except: title = "Null" try: rel = soup.find('link',{'rel':'canonical'})['href'] except: rel = "Null" try: content = soup.text content = content.replace('\n',"") except: content= "Null" return title, rel, content def extract_links(soup): links = soup.find_all('a') for link in links: if str(link.get('href')).startswith(url)== True and link.get('href') not in urls: if '.jpg' in link.get('href') or '.png' in link.get('href') or '.pdf' in link.get('href'): continue else: urls.append(link.get('href')) return (len(links)) def insert_data(data_from_url): url, title, rel, content = data_from_url cursor.execute("INSERT INTO websites (url,title,canonical,content) VALUES (?,?,?,?)",(url,title,rel,content)) db.commit() #save counter=0 while counter<len(urls): print(counter,"crawling:",urls[counter]) response = requests.get(urls[counter]) if response.status_code == 200: html = response.text soup = BeautifulSoup(html,'html.parser') links = extract_links(soup) title, rel, content = extract_content(soup) insert_data((urls[counter],title, rel, content)) counter+=1 ########### REGULAR EXPRESSIONS ################### # \n --> next line # \d --> digit # \t --> space of tab speech = ''' I have a dream that one day down in Alabama, with its vicious racists, with its governor having his lips dripping with the words of interposition and nullification – one day right there in Alabama little black boys and black girls will be able to join hands with little white boys and white girls as sisters and brothers. I have a dream today. I have a dream that one day every valley shall be exalted and every hill and mountain shall be made low, the rough places will be made plain, and the crooked places will be made straight, and the glory of the Lord shall be revealed and all flesh shall see it together. ''' import re x = re.search('[A-Z][a-z][a-z][a-z][a-z]', speech) print(x) ## H.W. ''' make a program that takes platenumber as input from the user check if the input matches with the valid number plate: a valid number plate consists of two alphabets in the starting followed by two numbers, then a space and then three numbers. For eg: XX78 787 is a valid plate number. '''
[ "noreply@github.com" ]
rodincode.noreply@github.com
1f5ddebc052c25f4314ffeefa2fae27d6667e05a
1d04ccbcd9819b66360120df6221b5309ae90de4
/tests/test_US22.py
b6a15f2b6af4c5eb1adc7b6b980af51e4e002cdb
[]
no_license
yang12304/ssw555_GEDCOM
ed70f3f24507701bc64e6bc6e15aa880923f36ad
a371a90f9f76a7fb9af414e770316e75f09637d1
refs/heads/master
2020-04-01T08:32:08.615096
2018-10-09T17:11:40
2018-10-09T17:11:40
null
0
0
null
null
null
null
UTF-8
Python
false
false
943
py
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 9/24/18 # @Author : Zhiren Yang # @File : test_US22.py # @Software: PyCharm import unittest from UserStories.US22 import unique_ids class TestUniqueIds(unittest.TestCase): def test_unique_ids(self): self.assertRaises(Exception, unique_ids, [{'INDI': '@I1@'}, {'INDI': '@I1@'}], [{'FAM':'@F1@'}, {'FAM': '@F2@'}]) self.assertRaises(Exception, unique_ids, [{'INDI': '@I1@'}, {'INDI': '@I2@'}], [{'FAM':'@F1@'}, {'FAM': '@F1@'}]) self.assertRaises(Exception, unique_ids, [{'INDI': '@I1@'}, {'FAM': '@I1@'}]) self.assertRaises(Exception, unique_ids, [], [{'FAM':'@F1@'}, {'FAM':'@F1@'}]) self.assertRaises(Exception, unique_ids, [{'INDI': '@I1@'}, {'INDI': '@I1@'}], []) self.assertEqual(unique_ids([{'INDI': '@I1@'}, {'INDI': '@I2@'}], [{'FAM':'@F1@'}, {'FAM': '@F2@'}]), None) if __name__ == '__main__': unittest.main()
[ "noreply@github.com" ]
yang12304.noreply@github.com