Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Iker Martín Álvarez
Proteo
Commits
c2e4f043
Commit
c2e4f043
authored
Mar 10, 2023
by
Iker Martín Álvarez
Browse files
Created Python script to transform whole DF to resizes DFs. WIP. iterTimes.py must be removed.
parent
ec2bcc2a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Analysis/CreateResizeDataframe.py
0 → 100644
View file @
c2e4f043
import
sys
import
glob
import
numpy
as
np
import
pandas
as
pd
from
enum
import
Enum
class
G_enum
(
Enum
):
TOTAL_RESIZES
=
0
TOTAL_GROUPS
=
1
TOTAL_STAGES
=
2
GRANULARITY
=
3
SDR
=
4
ADR
=
5
DR
=
6
RED_METHOD
=
7
RED_STRATEGY
=
8
SPAWN_METHOD
=
9
SPAWN_STRATEGY
=
10
GROUPS
=
11
FACTOR_S
=
12
DIST
=
13
STAGE_TYPES
=
14
STAGE_TIMES
=
15
STAGE_BYTES
=
16
ITERS
=
17
ASYNCH_ITERS
=
18
T_ITER
=
19
T_STAGES
=
20
T_SPAWN
=
21
T_SPAWN_REAL
=
22
T_SR
=
23
T_AR
=
24
T_TOTAL
=
25
#Malleability specific
NP
=
0
NC
=
1
#columnsG = ["Total_Resizes", "Total_Groups", "Total_Stages", "Granularity", "SDR", "ADR", "DR", "Redistribution_Method", \
"Redistribution_Strategy"
,
"Spawn_Method"
,
"Spawn_Strategy"
,
"Groups"
,
"FactorS"
,
"Dist"
,
"Stage_Types"
,
"Stage_Times"
,
\
"Stage_Bytes"
,
"Iters"
,
"Asynch_Iters"
,
"T_iter"
,
"T_stages"
,
"T_spawn"
,
"T_spawn_real"
,
"T_SR"
,
"T_AR"
,
"T_total"
]
#26
columnsM
=
[
"NP"
,
"NC"
,
"Total_Stages"
,
"Granularity"
,
"SDR"
,
"ADR"
,
"DR"
,
"Redistribution_Method"
,
\
"Redistribution_Strategy"
,
"Spawn_Method"
,
"Spawn_Strategy"
,
"FactorS"
,
"Dist"
,
"Stage_Type"
,
"Stage_Time"
,
\
"Stage_Bytes"
,
"Iters"
,
"Asynch_Iters"
,
"T_iter"
,
"T_stages"
,
"T_spawn"
,
"T_spawn_real"
,
"T_SR"
,
"T_AR"
]
#24
def
copy_resize
(
row
,
dataM_it
,
resize
):
basic_indexes
=
[
G_enum
.
TOTAL_STAGES
.
value
,
G_enum
.
GRANULARITY
.
value
,
G_enum
.
SDR
.
value
,
\
G_enum
.
ADR
.
value
,
G_enum
.
DR
.
value
,
G_enum
.
STAGE_TYPES
.
value
,
\
G_enum
.
STAGE_TIMES
.
value
,
G_enum
.
STAGE_BYTES
.
value
]
array_actual_group
=
[
G_enum
.
FACTOR_S
.
value
,
G_enum
.
ITERS
.
value
,
G_enum
.
ASYNCH_ITERS
.
value
,
\
G_enum
.
T_SPAWN
.
value
,
G_enum
.
T_SPAWN_REAL
.
value
,
G_enum
.
T_SR
.
value
,
\
G_enum
.
T_AR
.
value
,
G_enum
.
T_ITER
.
value
,
G_enum
.
T_STAGES
.
value
]
array_next_group
=
[
G_enum
.
RED_METHOD
.
value
,
G_enum
.
RED_STRATEGY
.
value
,
\
G_enum
.
SPAWN_METHOD
.
value
,
G_enum
.
SPAWN_STRATEGY
.
value
]
dataM_it
[
G_enum
.
NP
.
value
]
=
row
[
G_enum
.
GROUPS
.
value
][
resize
]
dataM_it
[
G_enum
.
NC
.
value
]
=
row
[
G_enum
.
GROUPS
.
value
][
resize
+
1
]
dataM_it
[
G_enum
.
DIST
.
value
]
=
[
None
,
None
]
dataM_it
[
G_enum
.
DIST
.
value
][
0
]
=
row
[
G_enum
.
DIST
.
value
][
resize
]
dataM_it
[
G_enum
.
DIST
.
value
][
1
]
=
row
[
G_enum
.
DIST
.
value
][
resize
+
1
]
for
index
in
basic_indexes
:
dataM_it
[
index
]
=
row
[
index
]
for
index
in
array_actual_group
:
dataM_it
[
index
-
1
]
=
row
[
index
][
resize
]
for
index
in
array_next_group
:
dataM_it
[
index
]
=
row
[
index
][
resize
+
1
]
#-----------------------------------------------
def
create_resize_dataframe
(
dfG
,
dataM
):
it
=
-
1
for
row
in
dfG
.
itertuples
(
index
=
False
,
name
=
None
):
resizes
=
row
[
G_enum
.
TOTAL_RESIZES
.
value
]
for
resize
in
range
(
resizes
):
it
+=
1
dataM
[
it
].
append
(
[
None
]
*
len
(
columnsM
)
)
copy_resize
(
row
,
dataM
[
it
],
resize
)
#-----------------------------------------------
if
len
(
sys
.
argv
)
<
2
:
print
(
"The files name is missing
\n
Usage: python3 CreateResizeDataframe.py input_file.csv output_name.csv"
)
exit
(
1
)
input_name
=
sys
.
argv
[
1
]
if
len
(
sys
.
argv
)
>
2
:
name
=
sys
.
argv
[
2
]
else
:
name
=
"dataM"
print
(
"Csv name will be: "
+
name
+
".csv"
)
dfG
=
pd
.
read_csv
(
input_name
)
dataM
=
[]
create_resize_dataframe
(
dfG
,
dataM
)
#dfM = pd.DataFrame(dataM, columns=columnsM)
#Poner en TC el valor real y en TH el necesario para la app
#cond = dfM.TH != 0
#dfM.loc[cond, ['TC', 'TH']] = dfM.loc[cond, ['TH', 'TC']].values
#dfM.to_csv(name + 'M.csv')
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment