Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WindEnergyToolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
toolbox
WindEnergyToolbox
Commits
3d36d648
Commit
3d36d648
authored
9 years ago
by
mads
Browse files
Options
Downloads
Patches
Plain Diff
bugfix
parent
8b72969d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
wetb/hawc2/tests/test_htc_file.py
+41
-35
41 additions, 35 deletions
wetb/hawc2/tests/test_htc_file.py
with
41 additions
and
35 deletions
wetb/hawc2/tests/test_htc_file.py
+
41
−
35
View file @
3d36d648
...
...
@@ -24,25 +24,25 @@ class TestHtcFile(unittest.TestCase):
def
check_htc_file
(
self
,
f
):
with
open
(
f
)
as
fid
:
orglines
=
fid
.
readlines
()
htcfile
=
HTCFile
(
f
)
newlines
=
str
(
htcfile
).
split
(
"
\n
"
)
htcfile
.
save
(
self
.
testfilepath
+
'
tmp.htc
'
)
#with open(self.testfilepath + 'tmp.htc') as fid:
# newlines = fid.readlines()
for
i
,
(
org
,
new
)
in
enumerate
(
zip
(
orglines
,
newlines
),
1
):
fmt
=
lambda
x
:
x
.
strip
().
replace
(
"
\t
"
,
"
"
).
replace
(
"
"
,
"
"
).
replace
(
"
"
,
"
"
).
replace
(
"
"
,
"
"
).
replace
(
"
"
,
"
"
)
if
fmt
(
org
)
!=
fmt
(
new
):
print
(
"
----------%d-------------
"
%
i
)
print
(
fmt
(
org
))
print
(
fmt
(
new
))
self
.
assertEqual
(
fmt
(
org
),
fmt
(
new
))
break
print
()
assert
len
(
orglines
)
==
len
(
newlines
)
with
open
(
f
)
as
fid
:
orglines
=
fid
.
readlines
()
htcfile
=
HTCFile
(
f
)
newlines
=
str
(
htcfile
).
split
(
"
\n
"
)
htcfile
.
save
(
self
.
testfilepath
+
'
tmp.htc
'
)
#with open(self.testfilepath + 'tmp.htc') as fid:
# newlines = fid.readlines()
for
i
,
(
org
,
new
)
in
enumerate
(
zip
(
orglines
,
newlines
),
1
):
fmt
=
lambda
x
:
x
.
strip
().
replace
(
"
\t
"
,
"
"
).
replace
(
"
"
,
"
"
).
replace
(
"
"
,
"
"
).
replace
(
"
"
,
"
"
).
replace
(
"
"
,
"
"
)
if
fmt
(
org
)
!=
fmt
(
new
):
print
(
"
----------%d-------------
"
%
i
)
print
(
fmt
(
org
))
print
(
fmt
(
new
))
self
.
assertEqual
(
fmt
(
org
),
fmt
(
new
))
break
print
()
assert
len
(
orglines
)
==
len
(
newlines
)
def
test_htc_files
(
self
):
for
f
in
[
'
test3.htc
'
]:
...
...
@@ -92,7 +92,7 @@ class TestHtcFile(unittest.TestCase):
def
test_htcfile_setname
(
self
):
htcfile
=
HTCFile
()
htcfile
.
set_name
(
"
mytest
"
)
self
.
assertEqual
(
htcfile
.
filename
,
'
mytest.htc
'
)
self
.
assertEqual
(
htcfile
.
filename
,
'
../htc/
mytest.htc
'
)
...
...
@@ -108,16 +108,16 @@ class TestHtcFile(unittest.TestCase):
htcfile
=
HTCFile
()
htcfile
.
add_mann_turbulence
(
30.1
,
1.1
,
3.3
,
102
,
False
)
s
=
"""
begin mann;
create_turb_parameters
\t
30.1 1.1 3.3 102 0;
\t
L, alfaeps, gamma, seed, highfrq compensation
filename_u
\t
./turb/turb_wsp10_s0102u.bin;
filename_v
\t
./turb/turb_wsp10_s0102v.bin;
filename_w
\t
./turb/turb_wsp10_s0102w.bin;
box_dim_u
\t
4096 1.4652;
box_dim_v
\t
32 3.2258;
box_dim_w
\t
32 3.2258;
std_scaling
\t
1.000000 0.800000 0.500000;
"""
create_turb_parameters
\t
30.1 1.1 3.3 102 0;
\t
L, alfaeps, gamma, seed, highfrq compensation
filename_u
\t
./turb/turb_wsp10_s0102u.bin;
filename_v
\t
./turb/turb_wsp10_s0102v.bin;
filename_w
\t
./turb/turb_wsp10_s0102w.bin;
box_dim_u
\t
4096 1.4652;
box_dim_v
\t
32 3.2258;
box_dim_w
\t
32 3.2258;
std_scaling
\t
1.000000 0.800000 0.500000;
"""
for
a
,
b
in
zip
(
s
.
split
(
"
\n
"
),
str
(
htcfile
.
wind
.
mann
).
split
(
"
\n
"
)):
self
.
assertEqual
(
a
,
b
)
self
.
assertEqual
(
a
.
strip
(),
b
.
strip
()
)
def
test_sensors
(
self
):
...
...
@@ -125,11 +125,11 @@ class TestHtcFile(unittest.TestCase):
htcfile
.
set_name
(
"
test
"
)
htcfile
.
output
.
add_sensor
(
'
wind
'
,
'
free_wind
'
,
[
1
,
0
,
0
,
-
30
])
s
=
"""
begin output;
filename
\t
./res/test;
general time;
wind free_wind
\t
1 0 0 -30;
"""
filename
\t
./res/test;
general time;
wind free_wind
\t
1 0 0 -30;
"""
for
a
,
b
in
zip
(
s
.
split
(
"
\n
"
),
str
(
htcfile
.
output
).
split
(
"
\n
"
)):
self
.
assertEqual
(
a
,
b
)
self
.
assertEqual
(
a
.
strip
(),
b
.
strip
()
)
#print (htcfile)
...
...
@@ -153,8 +153,8 @@ class TestHtcFile(unittest.TestCase):
'
./launcher_test/ssystem_eigenanalysis.dat
'
,
'
./launcher_test
\\
mode*.dat
'
,
'
./res/dlc12_iec61400-1ed3/dlc12_wsp10_wdir000_s1004.sel
'
,
'
./res/dlc12_iec61400-1ed3/dlc12_wsp10_wdir000_s1004.dat
'
,
'
./res/rotor_check_inipos
'
,
'
./res/rotor_check_inipos2
'
]:
'
./res/rotor_check_inipos
.dat
'
,
'
./res/rotor_check_inipos2
.dat
'
]:
try
:
output_files
.
remove
(
f
)
except
ValueError
:
...
...
@@ -195,6 +195,12 @@ class TestHtcFile(unittest.TestCase):
self
.
assertIn
(
os
.
path
.
abspath
(
self
.
testfilepath
+
'
orientation.dat
'
),
[
os
.
path
.
abspath
(
f
)
for
f
in
htcfile
.
input_files
()])
self
.
assertIn
(
'
./data/NREL_5MW_st1.txt
'
,
htcfile
.
input_files
())
def
test_tjul_example
(
self
):
htcfile
=
HTCFile
(
self
.
testfilepath
+
"
./tjul.htc
"
,
"
.
"
)
htcfile
.
save
(
"
./temp.htc
"
)
if
__name__
==
"
__main__
"
:
#import sys;sys.argv = ['', 'Test.testName']
...
...
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