Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
pydensecrf
Commits
99805385
Commit
99805385
authored
Oct 12, 2017
by
Marvin Teichmann
Browse files
Automating tests for eigen libary.
parent
e668c4db
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
6 deletions
+36
-6
pydensecrf/test_eigen.py
pydensecrf/test_eigen.py
+36
-6
No files found.
pydensecrf/test_eigen.py
View file @
99805385
import
numpy
as
np
import
eigen
as
e
V
=
np
.
random
.
randn
(
3
).
astype
(
np
.
float32
)
M
=
np
.
random
.
randn
(
3
,
3
).
astype
(
np
.
float32
)
import
pytest
foo
=
e
.
vectorXf
(
V
)
assert
np
.
all
(
np
.
array
(
foo
)
==
V
)
foo
=
e
.
matrixXf
(
M
)
assert
np
.
all
(
np
.
array
(
foo
)
==
M
)
def
test_vector_conversion
():
np_vector
=
np
.
random
.
randn
(
3
).
astype
(
np
.
float32
)
c_vector
=
e
.
vectorXf
(
np_vector
)
assert
np
.
all
(
np
.
array
(
c_vector
)
==
np_vector
)
def
test_matrix_conversion
():
np_matrix
=
np
.
random
.
randn
(
3
,
3
).
astype
(
np
.
float32
)
assert
(
np_matrix
.
ndim
==
2
)
c_matrix
=
e
.
matrixXf
(
np_matrix
)
assert
np
.
all
(
np
.
array
(
c_matrix
)
==
np_matrix
)
def
test_wrong_dims
():
np_matrix
=
np
.
random
.
randn
(
3
,
3
,
3
).
astype
(
np
.
float32
)
assert
(
np_matrix
.
ndim
==
3
)
# c_matrix only supports ndim == 2
with
pytest
.
raises
(
ValueError
):
# Check whether a Value Error is raised
e
.
matrixXf
(
np_matrix
)
def
test_wrong_type
():
np_matrix
=
np
.
random
.
randn
(
3
,
3
,
3
).
astype
(
np
.
float64
)
# c_matrix requies type np.float32
with
pytest
.
raises
(
ValueError
):
# Check whether a Value Error is raised
e
.
matrixXf
(
np_matrix
)
def
test_none_type
():
np_matrix
=
None
with
pytest
.
raises
(
TypeError
):
# Check whether a Value Error is raised
e
.
matrixXf
(
np_matrix
)
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