Skip to content

Commit

Permalink
Added tabels making for multiple algorithms
Browse files Browse the repository at this point in the history
  • Loading branch information
Vl4d1sl0veZ4r1p0v committed Oct 12, 2020
1 parent f7393ce commit 24e8323
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 66 deletions.
20 changes: 12 additions & 8 deletions manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ def test_second_experiment_works():
"./data/Texts/Normal/INP_TEXT",
'-a',
"bruteforce",
'-a',
"z_function",
'-l',
'4200',
'-S',
Expand Down Expand Up @@ -232,13 +234,15 @@ def test_second_experiment_works():
key=lambda x:
length_list[occurences_list.index(x)])
length_list.sort()
statiscian.make_table_time_by_many_strings(
np.mean(results_times[0], axis=1),
occurences_list,
length_list
statiscian.make_tables_time_by_many_strings(
runing_times=np.mean(results_times, axis=2),
occurences=occurences_list,
substrings_lengths=length_list,
algorithms=parsed_args.a
)
statiscian.make_table_memory_by_many_strings(
np.mean(result_memory[0], axis=1),
occurences_list,
length_list
statiscian.make_tables_memory_by_many_strings(
memory_usage=np.mean(result_memory, axis=2),
occurences=occurences_list,
substrings_lengths=length_list,
algorithms=parsed_args.a,
)
86 changes: 28 additions & 58 deletions src/statisticians/simple_statiscian.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,48 +22,62 @@ def get_prepared_for_plotting(array: np.array):
stds[i] = np.std(array[i]) / np.sqrt(array.shape[1])
return means, stds

def make_table_time_by_many_strings(
def make_tables_time_by_many_strings(
self,
runing_times: np.array,
occurences: list,
substrings_lengths: list,
algorithms: list,
):
headers = ['<b>Substring length, letters</b>',
'<b>Amount of occurrences</b>',
'<b>Algorithm running time, seconds</b>']
'<b>Amount of occurrences</b>']
headers.extend(['<b>' + algorithm + '</b>'
for algorithm in algorithms])
values = [
substrings_lengths,
occurences,
]
values.extend(runing_times)
self.make_table_by_many_strings(
usage=runing_times,
headers=headers,
occurences=occurences,
substrings_lengths=substrings_lengths,
out_filename=os.path.join(
"results",
"time_" + str(datetime.datetime.now()) + '.png'
)
),
values=values,
)

def make_table_memory_by_many_strings(
def make_tables_memory_by_many_strings(
self,
runing_times: np.array,
memory_usage: np.array,
occurences: list,
substrings_lengths: list,
algorithms: list,
):
headers = ['<b>Substring length, letters</b>',
'<b>Amount of occurrences</b>',
'<b>Algorithm memory usage, MiB</b>']
'<b>Amount of occurrences</b>']
headers.extend(['<b>' + algorithm + '</b>'
for algorithm in algorithms])
values = [
substrings_lengths,
occurences,
]
values.extend(memory_usage)
self.make_table_by_many_strings(
usage=runing_times,
headers=headers,
occurences=occurences,
substrings_lengths=substrings_lengths,
out_filename=os.path.join(
"results",
"memory_" + str(datetime.datetime.now()) + '.png'
)
),
values=values,
)

@staticmethod
def make_table_by_many_strings(usage: np.array,
def make_table_by_many_strings(values: list,
headers: list,
occurences: list,
substrings_lengths: list,
Expand All @@ -72,46 +86,6 @@ def make_table_by_many_strings(usage: np.array,
header_color = 'blue'
row_even_color = 'lightskyblue'
row_odd_color = 'white'

fig = go.Figure(data=[go.Table(
header=dict(
values=headers,
line_color='darkslategray',
fill_color=header_color,
align='center',
font=dict(color='white', size=12)
),
cells=dict(
values=[
substrings_lengths,
occurences,
usage,
],
line_color='darkslategray',
fill_color=[
[
[row_even_color, row_odd_color][i % 2]
for i in range(n)
] * 3
],
align='center',
font=dict(color='black', size=13)
))
])
fig.update_layout(width=600, height=600)
fig.write_image(out_filename)

@staticmethod
def make_tables_by_many_strings(usages: np.array,
headers: list,
occurences: list,
substrings_lengths: list,
out_filename: str):
n = len(occurences)
header_color = 'blue'
row_even_color = 'lightskyblue'
row_odd_color = 'white'

fig = go.Figure(data=[go.Table(
header=dict(
values=headers,
Expand All @@ -121,19 +95,15 @@ def make_tables_by_many_strings(usages: np.array,
font=dict(color='white', size=12)
),
cells=dict(
values=[
substrings_lengths,
occurences,
usages,
],
values=values,
line_color='darkslategray',
fill_color=[
[
[row_even_color, row_odd_color][i % 2]
for i in range(n)
] * 3
],
align='center',
align='left',
font=dict(color='black', size=13)
))
])
Expand Down

0 comments on commit 24e8323

Please sign in to comment.