Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cb-util
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christoph Alt
cb-util
Commits
b35d5a36
Commit
b35d5a36
authored
2 years ago
by
Christoph Alt
Browse files
Options
Downloads
Patches
Plain Diff
added parsing function for fe2ti
parent
6ebd1b1c
No related branches found
No related tags found
1 merge request
!2
Devel/fe2ti postprocessing
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cbutil/processing_functions.py
+19
-0
19 additions, 0 deletions
cbutil/processing_functions.py
tests/test_string_process.py
+61
-1
61 additions, 1 deletion
tests/test_string_process.py
with
80 additions
and
1 deletion
cbutil/processing_functions.py
+
19
−
0
View file @
b35d5a36
...
...
@@ -8,3 +8,22 @@ def mesa_pd_text(line: str):
return
m
.
group
(
1
),
float
(
m
.
group
(
2
))
raise
ValueError
()
def
fe2ti_parse_complete_timing
(
line
:
str
)
->
dict
:
if
not
line
.
startswith
(
"
Absolut
"
):
raise
ValueError
()
pattern
=
r
'
([A-Za-z][A-Za-z _]+):\s*(\d+\.\d+)s\s*
'
return
{
name
:
float
(
value
)
for
name
,
value
in
re
.
findall
(
pattern
,
line
)}
def
fe2ti_intermediate
(
line
:
str
)
->
dict
:
pattern_step_info
=
r
'
([A-Za-z_]+)\s+(\d+)\s*
'
step_info
=
{
name
:
cnt
for
name
,
cnt
in
re
.
findall
(
pattern_step_info
,
line
)}
if
not
step_info
:
raise
ValueError
(
"
Empty Step Info
"
)
pattern_fields
=
r
'
\s*([A-za-z_|0-9]+):\s*((\d+\.\d+e-\d+)|(\d+\.\d+)|(\d+))s?\s*
'
fields
=
{
name
:
float
(
value
)
for
name
,
value
,
*
_
in
re
.
findall
(
pattern_fields
,
line
)}
if
not
fields
:
raise
ValueError
(
"
Empty fields
"
)
return
{
'
step_info
'
:
step_info
,
'
fields
'
:
fields
}
This diff is collapsed.
Click to expand it.
tests/test_string_process.py
+
61
−
1
View file @
b35d5a36
from
cbutil.postprocessing
import
process_linewise
from
cbutil.processing_functions
import
mesa_pd_text
from
cbutil.processing_functions
import
mesa_pd_text
,
fe2ti_parse_complete_timing
,
fe2ti_intermediate
from
cbutil.util
import
read_file_line_wise
import
pytest
def
id
(
x
):
return
x
...
...
@@ -38,3 +40,61 @@ def test_mesa_pd():
for
key
,
value
in
process_linewise
(
mesa_pd_text
,
read_file_line_wise
(
mesa_pd_example_output
)):
assert
value
==
expected
[
key
]
TEST_STR_TOTAL
=
"
Absolut_gesamt: 49.09s Time to solution: 48.95s Create Macro Problem: 0.02s Comm_dup_etc: 0.05s
"
TEST_STR_INTERMEDIATE
=
"
load_step 00 lll_pen 00 Newton_load 01 Newton_gesamt 01 micro_solve: 15.61s Comm_for_couple: 0.02s Time_for_EV: 0.00s Macro_Solve: 0.56s Assembly_Macro: 0.55s KSP_Macro: 0.00s VecConvert: 0.00s iter_macro: 01 Micro_HDF5: 0.00s Comp_W: 0.00s Ass_Maj: 0.00s Comm_FLC: 0.00s FLC_Comp: 0.00s Ausw_Norm: 0.00s TimeDest: 0.00 DestBDDC: 0.00 SendBDDC: 0.00 CreateArrBDDC: 0.00 BDDC_Part: 0.00s PartAss: 0.00s PartKSP: 0.00s PartConv: 0.00s TimeDefo: 0.01s TimeInt: 0.00s ||delta_u||: 3.054712e-04
"
def
test_fe2ti
():
expected
=
{
"
Absolut_gesamt
"
:
49.09
,
"
Time to solution
"
:
48.95
,
"
Create Macro Problem
"
:
0.02
,
"
Comm_dup_etc
"
:
0.05
,
}
assert
fe2ti_parse_complete_timing
(
TEST_STR_TOTAL
)
==
expected
with
pytest
.
raises
(
ValueError
):
fe2ti_parse_complete_timing
(
TEST_STR_INTERMEDIATE
)
def
test_fe2ti_intermedate
():
expected
=
{
"
step_info
"
:
{
"
load_step
"
:
"
00
"
,
"
lll_pen
"
:
"
00
"
,
"
Newton_load
"
:
"
01
"
,
"
Newton_gesamt
"
:
"
01
"
,
},
"
fields
"
:
{
"
micro_solve
"
:
15.61
,
"
Comm_for_couple
"
:
0.02
,
"
Time_for_EV
"
:
0.00
,
"
Macro_Solve
"
:
0.56
,
"
Assembly_Macro
"
:
0.55
,
"
KSP_Macro
"
:
0.00
,
"
VecConvert
"
:
0.00
,
"
iter_macro
"
:
1.0
,
"
Micro_HDF5
"
:
0.00
,
"
Comp_W
"
:
0.00
,
"
Ass_Maj
"
:
0.00
,
"
Comm_FLC
"
:
0.00
,
"
FLC_Comp
"
:
0.00
,
"
Ausw_Norm
"
:
0.00
,
"
TimeDest
"
:
0.00
,
"
DestBDDC
"
:
0.00
,
"
SendBDDC
"
:
0.00
,
"
CreateArrBDDC
"
:
0.00
,
"
BDDC_Part
"
:
0.00
,
"
PartAss
"
:
0.00
,
"
PartKSP
"
:
0.00
,
"
PartConv
"
:
0.00
,
"
TimeDefo
"
:
0.01
,
"
TimeInt
"
:
0.00
,
"
||delta_u||
"
:
3.054712e-04
,
},
}
assert
fe2ti_intermediate
(
TEST_STR_INTERMEDIATE
)
==
expected
with
pytest
.
raises
(
ValueError
):
fe2ti_intermediate
(
TEST_STR_TOTAL
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment