filenames = ['pi_1000000.txt', 'pi_1000.txt', 'pi_100.txt', 'pi_30.txt' ] #filenames = ['pi_100.txt', 'pi_30.txt' ] filenames = list(reversed(filenames)) len_filenames = len(filenames) lines = [''] * len_filenames pi_str = [''] * len_filenames for n in range( len_filenames ): with open(filenames[n]) as f: lines[n] = f.readlines() pi_str[n] = strconvert(lines[n])[0:1] + strconvert(lines[n])[2:-1] # NOTE: below n = 0, 1, 2 indexes the three lengths of Pi being considered, and # x = 0, 1, 2, ..., 9 are the input values to be plotted against. E.g. x vs. F_n(x). domain = range(0,10) #Defines an array of Class Instantiations: CL[n][x] CL = [ [] ] * len_filenames for n in range(len_filenames): CL[n] = [ sbm(x, pi_str[n] ) for x in domain ] #Defines an array of Methodized classes: freq[n][x] freq = [ [] ] * len_filenames for n in range(len_filenames):
from jonmodule import Sub_in_main as sbm from jonmodule import strconvert import pygal import time s = time.time() filenames = ['pi_30.txt', 'pi_100.txt'] len_filenames = len(filenames) lines = [''] * len_filenames str_lines = [''] * len_filenames for n in range(len_filenames): with open(filenames[n]) as f: lines[n] = f.readlines() str_lines[n] = strconvert(lines[n])[0:1] + strconvert(lines[n])[2:-1] # NOTE: below n = 0, 1 indexes the two lengths of Pi being considered, and # x = 0, 1, 2, ..., 9 are the input values to be plotted against. E.g. x vs. F_n(x). domain = range(0, 10) # Defines an array of Class Instantiations, CL[n][x], # as made clear in the body of the for loop CL = [[]] * len_filenames # = [ [], [] ] since len_filenames == 2. # This list has two elements, Cl[0] = CL[1] = [], # each of which are empty LISTS, but will soon take form. for n in range(len_filenames): CL[n] = [sbm(x, str_lines[n]) for x in domain]
filenames = ['pi_30.txt'] #filenames = [ 'pi_30.txt','e_30.txt', 'phi_30.txt', 'sqrt2_30.txt' ] #filenames = ['pi_30.txt','e_30.txt' ] #filenames = [ 'phi_30.txt', 'sqrt2_30.txt'] len_filenames = len(filenames) lines = [''] * len_filenames str_lines = [''] * len_filenames snippet_str = [''] * len_filenames for n in range(len_filenames): with open(filenames[n]) as f: lines[n] = f.readlines() str_lines[n] = strconvert(lines[n])[0:1] + strconvert(lines[n])[2:-1] snippet_str[n] = strconvert(lines[n])[0:-1] # NOTE: below n = 0, 1 indexes the two lengths of Pi being considered, and # x = 0, 1, 2, ..., 9 are the input values to be plotted against. E.g. x vs. F_n(x). domain = range(0, 10) # Defines an array of Class Instantiations, CL[n][x], # as made clear in the body of the for loop CL = [[]] * len_filenames # = [ [], [] ] since len_filenames == 2. # This list has two elements, Cl[0] = CL[1] = [], # each of which are empty LISTS, but will soon take form. for n in range(len_filenames):
s=time.time() filenames = [ 'pi_30.txt', 'pi_100.txt' ] domain = range(0,10) lines = [] for item in filenames: with open(item) as f: lines_item = f.readlines() lines.append(lines_item ) str_lines = [] for item in lines: str_lines_item = strconvert(item)[0:1] + strconvert(item)[2:-1] str_lines.append(str_lines_item) CL = [] for item in str_lines: CL_item = [ sbm(x, item ) for x in domain ] CL.append(CL_item) freq = [] for CL_n in CL: freq_n = [ element.jcount() for element in CL_n ] freq.append(freq_n)