Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
P
pymor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Insights
Issue
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
pyMOR
pymor
Commits
ba84cd00
Commit
ba84cd00
authored
Apr 20, 2020
by
René Fritze
Committed by
René Fritze
Jun 26, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[test] refactor gram_schmidt tests
parent
54c3f5eb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
14 deletions
+13
-14
src/pymortests/algorithms/gram_schmidt.py
src/pymortests/algorithms/gram_schmidt.py
+13
-14
No files found.
src/pymortests/algorithms/gram_schmidt.py
View file @
ba84cd00
...
...
@@ -3,10 +3,14 @@
# License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
import
numpy
as
np
from
hypothesis
import
given
,
settings
,
assume
,
reproduce_failure
import
pytest
from
hypothesis
import
given
,
settings
,
assume
,
reproduce_failure
,
example
from
pymor.algorithms.basic
import
almost_equal
from
pymor.algorithms.gram_schmidt
import
gram_schmidt
,
gram_schmidt_biorth
from
pymor.core.logger
import
getLogger
,
scoped_logger
from
pymor.tools.floatcmp
import
contains_zero_vector
from
pymor.vectorarrays.numpy
import
NumpyVectorArray
,
NumpyVectorSpace
from
pymortests.base
import
runmodule
from
pymortests.fixtures.operator
import
operator_with_arrays_and_products
import
pymortests.strategies
as
pyst
...
...
@@ -15,6 +19,9 @@ import pymortests.strategies as pyst
@
given
(
pyst
.
vector_arrays
(
count
=
1
))
def
test_gram_schmidt
(
vector_array
):
U
=
vector_array
[
0
]
# TODO assumption here masks a potential issue with the algorithm
# where it fails in del instead of a proper error
assume
(
len
(
U
)
>
1
or
not
contains_zero_vector
(
U
))
V
=
U
.
copy
()
onb
=
gram_schmidt
(
U
,
copy
=
True
)
...
...
@@ -75,24 +82,16 @@ def test_gram_schmidt_with_product_and_R(operator_with_arrays_and_products):
assert
np
.
all
(
almost_equal
(
onb
,
U
))
@
given
(
pyst
.
vector_arrays
(
count
=
1
))
@
given
(
pyst
.
base_vector_arrays
(
count
=
2
))
@
settings
(
deadline
=
None
)
def
test_gram_schmidt_biorth
(
vector_array
):
U
=
vector_array
[
0
]
assume
(
U
.
dim
>=
2
)
l
=
len
(
U
)
//
2
l
=
min
((
l
,
U
.
dim
-
1
))
assume
(
l
>=
1
)
U1
=
U
[:
l
].
copy
()
U2
=
U
[
l
:
2
*
l
].
copy
()
def
test_gram_schmidt_biorth
(
vector_arrays
):
U1
,
U2
=
vector_arrays
V1
=
U1
.
copy
()
V2
=
U2
.
copy
()
from
pprint
import
pprint
pprint
(
U1
.
to_numpy
())
pprint
(
U2
.
to_numpy
())
A1
,
A2
=
gram_schmidt_biorth
(
U1
,
U2
,
copy
=
True
)
with
scoped_logger
(
'pymor.algorithms.gram_schmidt.gram_schmidt_biorth'
,
level
=
'FATAL'
):
A1
,
A2
=
gram_schmidt_biorth
(
U1
,
U2
,
copy
=
True
)
assert
np
.
all
(
almost_equal
(
U1
,
V1
))
assert
np
.
all
(
almost_equal
(
U2
,
V2
))
assert
np
.
allclose
(
A2
.
dot
(
A1
),
np
.
eye
(
len
(
A1
)))
...
...
Write
Preview
Markdown
is supported
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