Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
BayesValidRox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
inversemodeling
BayesValidRox
Commits
bc50ca0c
Commit
bc50ca0c
authored
5 months ago
by
kohlhaasrebecca
Browse files
Options
Downloads
Patches
Plain Diff
[tests] Add some PCE PostProcessing tests
parent
553c98ff
No related branches found
No related tags found
1 merge request
!37
Fix/post processing
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/bayesvalidrox/post_processing/post_processing.py
+43
-0
43 additions, 0 deletions
src/bayesvalidrox/post_processing/post_processing.py
tests/test_PostProcessing.py
+11
-0
11 additions, 0 deletions
tests/test_PostProcessing.py
with
54 additions
and
0 deletions
src/bayesvalidrox/post_processing/post_processing.py
+
43
−
0
View file @
bc50ca0c
...
...
@@ -563,12 +563,21 @@ class PostProcessing:
"""
# This function currently only supports PCE/aPCE
<<<<<<<
HEAD
metamod
=
self
.
engine
.
MetaModel
if
not
hasattr
(
metamod
,
'
meta_model_type
'
):
raise
AttributeError
(
'
Sobol indices only support PCE-type models!
'
)
if
metamod
.
meta_model_type
.
lower
()
not
in
[
'
pce
'
,
'
apce
'
]:
raise
AttributeError
(
'
Sobol indices only support PCE-type models!
'
)
=======
PCEModel
=
self
.
engine
.
MetaModel
if
not
hasattr
(
PCEModel
,
'
meta_model_type
'
):
raise
AttributeError
(
'
Sobol indices only support PCE-type models!
'
)
if
PCEModel
.
meta_model_type
.
lower
()
not
in
[
'
pce
'
,
'
apce
'
]:
raise
AttributeError
(
'
Sobol indices only support PCE-type models!
'
)
>>>>>>>
a58a509a
([
tests
]
Add
some
PCE
PostProcessing
tests
)
# Extract the necessary variables
basis_dict
=
metamod
.
_basis_dict
coeffs_dict
=
metamod
.
_coeffs_dict
...
...
@@ -966,6 +975,7 @@ class PostProcessing:
plt
.
close
()
# -------------------------------------------------------------------------
<<<<<<<
HEAD
def
plot_metamodel_3d
(
self
,
n_samples
=
10
):
"""
Visualize the results of a PCE MetaModel as a 3D surface over two input
...
...
@@ -980,6 +990,18 @@ class PostProcessing:
------
AttributeError
This function is only applicable if the MetaModel input dimension is 2.
=======
def eval_pce_model_3d(self):
# This function currently only supports PCE/aPCE
PCEModel = self.engine.MetaModel
if not hasattr(PCEModel,
'
meta_model_type
'
):
raise AttributeError(
'
This evaluation only support PCE-type models!
'
)
if PCEModel.meta_model_type.lower() not in [
'
pce
'
,
'
apce
'
]:
raise AttributeError(
'
This evaluation only support PCE-type models!
'
)
self.n_samples = 1000
n_samples = self.n_samples
>>>
>>>>
a58a509a
([
tests
]
Add
some
PCE
PostProcessing
tests
)
Returns
-------
...
...
@@ -1074,6 +1096,7 @@ class PostProcessing:
"""
# This function currently only supports PCE/aPCE
<<<<<<<
HEAD
metamod
=
self
.
engine
.
MetaModel
if
not
hasattr
(
metamod
,
'
meta_model_type
'
):
raise
AttributeError
(
...
...
@@ -1081,6 +1104,14 @@ class PostProcessing:
if
metamod
.
meta_model_type
.
lower
()
not
in
[
'
pce
'
,
'
apce
'
]:
raise
AttributeError
(
'
This evaluation only support PCE-type models!
'
)
=======
PCEModel
=
self
.
engine
.
MetaModel
if
not
hasattr
(
PCEModel
,
'
meta_model_type
'
):
raise
AttributeError
(
'
This evaluation only support PCE-type models!
'
)
if
PCEModel
.
meta_model_type
.
lower
()
not
in
[
'
pce
'
,
'
apce
'
]:
raise
AttributeError
(
'
This evaluation only support PCE-type models!
'
)
>>>>>>>
a58a509a
([
tests
]
Add
some
PCE
PostProcessing
tests
)
# get the samples
y_pce_val
=
self
.
pce_out_mean
...
...
@@ -1159,6 +1190,7 @@ class PostProcessing:
"""
# This function currently only supports PCE/aPCE
<<<<<<<
HEAD
metamod
=
self
.
engine
.
MetaModel
if
not
hasattr
(
metamod
,
'
meta_model_type
'
):
raise
AttributeError
(
...
...
@@ -1166,6 +1198,17 @@ class PostProcessing:
if
metamod
.
meta_model_type
.
lower
()
not
in
[
'
pce
'
,
'
apce
'
]:
raise
AttributeError
(
'
This evaluation only support PCE-type models!
'
)
=======
PCEModel
=
self
.
engine
.
MetaModel
if
not
hasattr
(
PCEModel
,
'
meta_model_type
'
):
raise
AttributeError
(
'
This evaluation only support PCE-type models!
'
)
if
PCEModel
.
meta_model_type
.
lower
()
not
in
[
'
pce
'
,
'
apce
'
]:
raise
AttributeError
(
'
This evaluation only support PCE-type models!
'
)
newpath
=
f
'
Outputs_PostProcessing_
{
self
.
name
}
/
'
if
not
os
.
path
.
exists
(
newpath
):
os
.
makedirs
(
newpath
)
>>>>>>>
a58a509a
([
tests
]
Add
some
PCE
PostProcessing
tests
)
# List of markers and colors
color
=
cycle
(([
'
b
'
,
'
g
'
,
'
r
'
,
'
y
'
,
'
k
'
]))
...
...
This diff is collapsed.
Click to expand it.
tests/test_PostProcessing.py
+
11
−
0
View file @
bc50ca0c
...
...
@@ -149,6 +149,7 @@ def test_sobol_indices_pce(pce_engine) -> None:
assert
sobol
[
'
Z
'
][
0
,
0
]
==
1
#%% check_reg_quality
<<<<<<<
HEAD
def
test_check_reg_quality_pce
(
pce_engine
)
->
None
:
"""
...
...
@@ -161,14 +162,24 @@ def test_check_reg_quality_pce(pce_engine) -> None:
#%% eplot_metamodel_3d
def
test_plot_metamodel_3d_nopce
(
basic_engine
)
->
None
:
=======
#%% eval_pce_model_3d
def
test_eval_pce_model_3d_nopce
(
basic_engine
)
->
None
:
>>>>>>>
a58a509a
([
tests
]
Add
some
PCE
PostProcessing
tests
)
"""
3d eval of non-PCE metamodel
"""
engine
=
basic_engine
post
=
PostProcessing
(
engine
)
with
pytest
.
raises
(
AttributeError
)
as
excinfo
:
<<<<<<<
HEAD
post
.
plot_metamodel_3d
()
assert
str
(
excinfo
.
value
)
==
'
This function is only applicable if the MetaModel input dimension is 2.
'
=======
post
.
eval_pce_model_3d
()
assert
str
(
excinfo
.
value
)
==
'
This evaluation only support PCE-type models!
'
>>>>>>>
a58a509a
([
tests
]
Add
some
PCE
PostProcessing
tests
)
#%% _get_sample
...
...
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