Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor 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
schwede
openstructure
Commits
22cb2257
Commit
22cb2257
authored
7 years ago
by
Gerardo Tauriello
Browse files
Options
Downloads
Patches
Plain Diff
Enabled and fixed numpy unit test
parent
bced8e6a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/mol/base/tests/CMakeLists.txt
+1
-1
1 addition, 1 deletion
modules/mol/base/tests/CMakeLists.txt
modules/mol/base/tests/test_numpy.py
+24
-23
24 additions, 23 deletions
modules/mol/base/tests/test_numpy.py
with
25 additions
and
24 deletions
modules/mol/base/tests/CMakeLists.txt
+
1
−
1
View file @
22cb2257
...
...
@@ -17,7 +17,7 @@ set(OST_MOL_BASE_UNIT_TESTS
)
if
(
USE_NUMPY
)
set
(
OST_MOST_BASE_UNIT_TESTS
"
${
OST_MO
ST
_BASE_UNIT_TESTS
}
"
test_numpy.py
)
list
(
APPEND
OST_MO
L
_BASE_UNIT_TESTS test_numpy.py
)
endif
(
USE_NUMPY
)
ost_unittest
(
MODULE mol SOURCES
"
${
OST_MOL_BASE_UNIT_TESTS
}
"
)
...
...
This diff is collapsed.
Click to expand it.
modules/mol/base/tests/test_numpy.py
+
24
−
23
View file @
22cb2257
...
...
@@ -5,6 +5,7 @@ if __name__== '__main__':
sys
.
path
.
insert
(
0
,
"
../../../../stage/lib/openstructure/
"
)
import
ost
from
ost
import
geom
,
mol
if
ost
.
WITH_NUMPY
:
has_numpy
=
True
...
...
@@ -16,10 +17,10 @@ else:
has_numpy
=
False
def
v2v
(
v
):
return
ost
.
geom
.
Vec3
(
float
(
v
[
0
]),
float
(
v
[
1
]),
float
(
v
[
2
]))
return
geom
.
Vec3
(
float
(
v
[
0
]),
float
(
v
[
1
]),
float
(
v
[
2
]))
def
dd
(
v1
,
v2
):
return
ost
.
geom
.
Distance
(
v1
,
v2
)
<
1e-8
return
geom
.
Distance
(
v1
,
v2
)
<
1e-8
class
TestNumpy
(
unittest
.
TestCase
):
def
setUp
(
self
):
...
...
@@ -28,46 +29,46 @@ class TestNumpy(unittest.TestCase):
def
test_
(
self
):
if
not
has_numpy
:
return
entity
=
ost
.
mol
.
CreateEntity
()
entity
=
mol
.
CreateEntity
()
ed
=
entity
.
EditXCS
()
ch
=
ed
.
InsertChain
(
"
X
"
)
re
=
ed
.
AppendResidue
(
ch
,
"
ALA
"
)
a0
=
ed
.
InsertAtom
(
re
,
"
A
"
,
ost
.
geom
.
Vec3
(
0
,
0
,
0
))
a0
=
ed
.
InsertAtom
(
re
,
"
A
"
,
geom
.
Vec3
(
0
,
0
,
0
))
self
.
assertEqual
(
a0
.
GetIndex
(),
0
)
a1
=
ed
.
InsertAtom
(
re
,
"
B
"
,
ost
.
geom
.
Vec3
(
1
,
0
,
0
))
a1
=
ed
.
InsertAtom
(
re
,
"
B
"
,
geom
.
Vec3
(
1
,
0
,
0
))
self
.
assertEqual
(
a1
.
GetIndex
(),
1
)
a2
=
ed
.
InsertAtom
(
re
,
"
C
"
,
ost
.
geom
.
Vec3
(
2
,
0
,
0
))
a2
=
ed
.
InsertAtom
(
re
,
"
C
"
,
geom
.
Vec3
(
2
,
0
,
0
))
self
.
assertEqual
(
a2
.
GetIndex
(),
2
)
a3
=
ed
.
InsertAtom
(
re
,
"
D
"
,
ost
.
geom
.
Vec3
(
3
,
0
,
0
))
a3
=
ed
.
InsertAtom
(
re
,
"
D
"
,
geom
.
Vec3
(
3
,
0
,
0
))
self
.
assertEqual
(
a3
.
GetIndex
(),
3
)
self
.
assertTrue
(
dd
(
a0
.
pos
,
ost
.
geom
.
Vec3
(
0
,
0
,
0
)))
self
.
assertTrue
(
dd
(
a1
.
pos
,
ost
.
geom
.
Vec3
(
1
,
0
,
0
)))
self
.
assertTrue
(
dd
(
a2
.
pos
,
ost
.
geom
.
Vec3
(
2
,
0
,
0
)))
self
.
assertTrue
(
dd
(
a3
.
pos
,
ost
.
geom
.
Vec3
(
3
,
0
,
0
)))
self
.
assertTrue
(
dd
(
a0
.
pos
,
geom
.
Vec3
(
0
,
0
,
0
)))
self
.
assertTrue
(
dd
(
a1
.
pos
,
geom
.
Vec3
(
1
,
0
,
0
)))
self
.
assertTrue
(
dd
(
a2
.
pos
,
geom
.
Vec3
(
2
,
0
,
0
)))
self
.
assertTrue
(
dd
(
a3
.
pos
,
geom
.
Vec3
(
3
,
0
,
0
)))
ed
.
SetAtomTransformedPos
(
entity
.
GetAtomList
(),
numpy
.
array
([[
0
,
1
,
0
],[
0
,
2
,
0
],[
0
,
3
,
0
],[
0
,
4
,
0
]],
dtype
=
numpy
.
float32
))
self
.
assertTrue
(
dd
(
a0
.
pos
,
ost
.
geom
.
Vec3
(
0
,
1
,
0
)))
self
.
assertTrue
(
dd
(
a1
.
pos
,
ost
.
geom
.
Vec3
(
0
,
2
,
0
)))
self
.
assertTrue
(
dd
(
a2
.
pos
,
ost
.
geom
.
Vec3
(
0
,
3
,
0
)))
self
.
assertTrue
(
dd
(
a3
.
pos
,
ost
.
geom
.
Vec3
(
0
,
4
,
0
)))
self
.
assertTrue
(
dd
(
a0
.
pos
,
geom
.
Vec3
(
0
,
1
,
0
)))
self
.
assertTrue
(
dd
(
a1
.
pos
,
geom
.
Vec3
(
0
,
2
,
0
)))
self
.
assertTrue
(
dd
(
a2
.
pos
,
geom
.
Vec3
(
0
,
3
,
0
)))
self
.
assertTrue
(
dd
(
a3
.
pos
,
geom
.
Vec3
(
0
,
4
,
0
)))
na
=
entity
.
positions
self
.
assertTrue
(
dd
(
v2v
(
na
[
0
]),
ost
.
geom
.
Vec3
(
0
,
1
,
0
)))
self
.
assertTrue
(
dd
(
v2v
(
na
[
1
]),
ost
.
geom
.
Vec3
(
0
,
2
,
0
)))
self
.
assertTrue
(
dd
(
v2v
(
na
[
2
]),
ost
.
geom
.
Vec3
(
0
,
3
,
0
)))
self
.
assertTrue
(
dd
(
v2v
(
na
[
3
]),
ost
.
geom
.
Vec3
(
0
,
4
,
0
)))
self
.
assertTrue
(
dd
(
v2v
(
na
[
0
]),
geom
.
Vec3
(
0
,
1
,
0
)))
self
.
assertTrue
(
dd
(
v2v
(
na
[
1
]),
geom
.
Vec3
(
0
,
2
,
0
)))
self
.
assertTrue
(
dd
(
v2v
(
na
[
2
]),
geom
.
Vec3
(
0
,
3
,
0
)))
self
.
assertTrue
(
dd
(
v2v
(
na
[
3
]),
geom
.
Vec3
(
0
,
4
,
0
)))
ed
.
SetAtomTransformedPos
([
3
,
99
,
2
],
numpy
.
array
([[
0
,
0
,
-
3
],[
-
1
,
-
1
,
-
1
],[
0
,
0
,
-
2
]],
dtype
=
numpy
.
float32
))
self
.
assertTrue
(
dd
(
a0
.
pos
,
ost
.
geom
.
Vec3
(
0
,
1
,
0
)))
self
.
assertTrue
(
dd
(
a1
.
pos
,
ost
.
geom
.
Vec3
(
0
,
2
,
0
)))
self
.
assertTrue
(
dd
(
a2
.
pos
,
ost
.
geom
.
Vec3
(
0
,
0
,
-
2
)))
self
.
assertTrue
(
dd
(
a3
.
pos
,
ost
.
geom
.
Vec3
(
0
,
0
,
-
3
)))
self
.
assertTrue
(
dd
(
a0
.
pos
,
geom
.
Vec3
(
0
,
1
,
0
)))
self
.
assertTrue
(
dd
(
a1
.
pos
,
geom
.
Vec3
(
0
,
2
,
0
)))
self
.
assertTrue
(
dd
(
a2
.
pos
,
geom
.
Vec3
(
0
,
0
,
-
2
)))
self
.
assertTrue
(
dd
(
a3
.
pos
,
geom
.
Vec3
(
0
,
0
,
-
3
)))
if
__name__
==
'
__main__
'
:
unittest
.
main
()
...
...
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