-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.py
More file actions
35 lines (32 loc) · 1.64 KB
/
data.py
File metadata and controls
35 lines (32 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import numpy as np
from reducedModules import reduced_module, type_tests
from partitions import quick_partition
# We compute for all modules of all dimensions up to a maximum.
# One enters the maximum dimension to be considered and the name of
# the file under which to save the data.
max_dim = int(input("Enter the maximum dimension: "))
name = str(input("Name file to save data under: "))
data = {} # Here we store all data computed
for dim in range(2,max_dim+1): # Loop over all dimensions
counter = np.array([2,0,0,0])
partitions = list(quick_partition(dim)) # Compute the partitions
N = len(partitions) # How many partitions?
for YD in partitions: # Loop over all YDs of that
if len(YD)>1 and YD[0]>1: # dimension.
(SH,G) = reduced_module(YD) # Compute reduced module
types = type_tests(SH,G) # Compute its types
if(types == [0,0,0,0]): # Check for impossible behaviour
print("PROBELM")
break
counter = np.add(types,counter) # Add to counter.
# Compute distribution for that
# dimension in %.
data[dim] = tuple(round(100*(counter[i])/N,2) for i in range(4))
# We write the data computed to the file named above.
f = open(name + ".txt","x")
f.write("{:<4} {:<10} {:<10} {:<10} {:<10}".format('Dim','T1','T2','T3','T4'))
for dim, c in data.items():
t1,t2,t3,t4=c
f.write("\n")
f.write("{:<4} {:<10} {:<10} {:<10} {:<10}".format(dim, t1,t2,t3,t4))
f.close()