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
dlib
Commits
99b0f687
"tests/vscode:/vscode.git/clone" did not exist on "cd9599ab0493e365977458e100da6218243f1fcb"
Commit
99b0f687
authored
Jan 16, 2018
by
Davis King
Browse files
Fixed test to really work if numpy isn't installed.
parent
a9ca83d2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
19 deletions
+20
-19
tools/python/test/test_matrix.py
tools/python/test/test_matrix.py
+20
-19
No files found.
tools/python/test/test_matrix.py
View file @
99b0f687
...
@@ -7,9 +7,9 @@ from pytest import raises
...
@@ -7,9 +7,9 @@ from pytest import raises
try
:
try
:
import
numpy
import
numpy
have_numpy
=
True
except
ImportError
:
except
ImportError
:
# Just skip these tests if numpy isn't installed
have_numpy
=
False
exit
(
0
)
def
test_matrix_empty_init
():
def
test_matrix_empty_init
():
...
@@ -57,23 +57,24 @@ def test_matrix_from_list_as_column_vector():
...
@@ -57,23 +57,24 @@ def test_matrix_from_list_as_column_vector():
assert
str
(
m
)
==
"0
\n
1
\n
2"
assert
str
(
m
)
==
"0
\n
1
\n
2"
def
test_matrix_from_object_with_2d_shape
():
if
have_numpy
:
m1
=
numpy
.
array
([[
0
,
1
,
2
],
def
test_matrix_from_object_with_2d_shape
():
[
3
,
4
,
5
],
m1
=
numpy
.
array
([[
0
,
1
,
2
],
[
6
,
7
,
8
]])
[
3
,
4
,
5
],
m
=
matrix
(
m1
)
[
6
,
7
,
8
]])
assert
m
.
nr
()
==
3
m
=
matrix
(
m1
)
assert
m
.
nc
()
==
3
assert
m
.
nr
()
==
3
assert
m
.
shape
==
(
3
,
3
)
assert
m
.
nc
()
==
3
assert
len
(
m
)
==
3
assert
m
.
shape
==
(
3
,
3
)
assert
repr
(
m
)
==
"< dlib.matrix containing:
\n
0 1 2
\n
3 4 5
\n
6 7 8 >"
assert
len
(
m
)
==
3
assert
str
(
m
)
==
"0 1 2
\n
3 4 5
\n
6 7 8"
assert
repr
(
m
)
==
"< dlib.matrix containing:
\n
0 1 2
\n
3 4 5
\n
6 7 8 >"
assert
str
(
m
)
==
"0 1 2
\n
3 4 5
\n
6 7 8"
def
test_matrix_from_object_without_2d_shape
():
with
raises
(
IndexError
):
def
test_matrix_from_object_without_2d_shape
():
m1
=
numpy
.
array
([
0
,
1
,
2
])
with
raises
(
IndexError
):
matrix
(
m1
)
m1
=
numpy
.
array
([
0
,
1
,
2
])
matrix
(
m1
)
def
test_matrix_from_object_without_shape
():
def
test_matrix_from_object_without_shape
():
...
...
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