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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
schwede
openstructure
Commits
aa464505
Commit
aa464505
authored
Aug 2, 2011
by
Ansgar Philippsen
Browse files
Options
Downloads
Patches
Plain Diff
fixed numpy detection for some tests
parent
9d1c0d6d
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
modules/base/pymod/wrap_base.cc
+1
-0
1 addition, 0 deletions
modules/base/pymod/wrap_base.cc
modules/gfx/tests/test_gfx.py
+8
-4
8 additions, 4 deletions
modules/gfx/tests/test_gfx.py
modules/mol/base/tests/test_numpy.py
+36
-28
36 additions, 28 deletions
modules/mol/base/tests/test_numpy.py
with
45 additions
and
32 deletions
modules/base/pymod/wrap_base.cc
+
1
−
0
View file @
aa464505
...
...
@@ -50,6 +50,7 @@ BOOST_PYTHON_MODULE(_ost_base)
scope
().
attr
(
"VERSION_MAJOR"
)
=
OST_VERSION_MAJOR
;
scope
().
attr
(
"VERSION_MINOR"
)
=
OST_VERSION_MINOR
;
scope
().
attr
(
"VERSION_PATCH"
)
=
OST_VERSION_PATCH
;
scope
().
attr
(
"WITH_NUMPY"
)
=
OST_NUMPY_SUPPORT_ENABLED
;
export_Logger
();
export_Range
();
export_Units
();
...
...
...
...
This diff is collapsed.
Click to expand it.
modules/gfx/tests/test_gfx.py
+
8
−
4
View file @
aa464505
...
...
@@ -9,9 +9,13 @@ import ost.mol as mol
import
ost.gfx
as
gfx
import
ost.geom
as
geom
if
ost
.
WITH_NUMPY
:
has_numpy
=
True
try
:
import
numpy
if
not
has_numpy
:
except
ImportError
,
e
:
has_numpy
=
False
else
:
has_numpy
=
False
def
col_delta
(
c1
,
c2
):
...
...
...
...
This diff is collapsed.
Click to expand it.
modules/mol/base/tests/test_numpy.py
+
36
−
28
View file @
aa464505
import
unittest
from
ost
import
*
if
__name__
==
'
__main__
'
:
import
sys
sys
.
path
.
insert
(
0
,
"
../../../../stage/lib64/openstructure/
"
)
sys
.
path
.
insert
(
0
,
"
../../../../stage/lib/openstructure/
"
)
import
ost
if
ost
.
WITH_NUMPY
:
has_numpy
=
True
try
:
import
numpy
except
ImportError
:
except
ImportError
,
e
:
has_numpy
=
False
else
:
has_numpy
=
False
def
v2v
(
v
):
return
geom
.
Vec3
(
float
(
v
[
0
]),
float
(
v
[
1
]),
float
(
v
[
2
]))
return
ost
.
geom
.
Vec3
(
float
(
v
[
0
]),
float
(
v
[
1
]),
float
(
v
[
2
]))
def
dd
(
v1
,
v2
):
return
geom
.
Distance
(
v1
,
v2
)
<
1e-8
return
ost
.
geom
.
Distance
(
v1
,
v2
)
<
1e-8
class
TestNumpy
(
unittest
.
TestCase
):
def
setUp
(
self
):
...
...
@@ -20,46 +28,46 @@ class TestNumpy(unittest.TestCase):
def
test_
(
self
):
if
not
has_numpy
:
return
entity
=
mol
.
CreateEntity
()
entity
=
ost
.
mol
.
CreateEntity
()
ed
=
entity
.
EditXCS
()
ch
=
ed
.
InsertChain
(
"
X
"
)
re
=
ed
.
AppendResidue
(
ch
,
"
ALA
"
)
a0
=
ed
.
InsertAtom
(
re
,
"
A
"
,
geom
.
Vec3
(
0
,
0
,
0
))
a0
=
ed
.
InsertAtom
(
re
,
"
A
"
,
ost
.
geom
.
Vec3
(
0
,
0
,
0
))
self
.
assertEqual
(
a0
.
GetIndex
(),
0
)
a1
=
ed
.
InsertAtom
(
re
,
"
B
"
,
geom
.
Vec3
(
1
,
0
,
0
))
a1
=
ed
.
InsertAtom
(
re
,
"
B
"
,
ost
.
geom
.
Vec3
(
1
,
0
,
0
))
self
.
assertEqual
(
a1
.
GetIndex
(),
1
)
a2
=
ed
.
InsertAtom
(
re
,
"
C
"
,
geom
.
Vec3
(
2
,
0
,
0
))
a2
=
ed
.
InsertAtom
(
re
,
"
C
"
,
ost
.
geom
.
Vec3
(
2
,
0
,
0
))
self
.
assertEqual
(
a2
.
GetIndex
(),
2
)
a3
=
ed
.
InsertAtom
(
re
,
"
D
"
,
geom
.
Vec3
(
3
,
0
,
0
))
a3
=
ed
.
InsertAtom
(
re
,
"
D
"
,
ost
.
geom
.
Vec3
(
3
,
0
,
0
))
self
.
assertEqual
(
a3
.
GetIndex
(),
3
)
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
)))
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
)))
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
,
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
)))
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
)))
na
=
entity
.
positions
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
)))
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
)))
ed
.
SetAtomTransformedPos
([
3
,
99
,
2
],
numpy
.
array
([[
0
,
0
,
-
3
],[
-
1
,
-
1
,
-
1
],[
0
,
0
,
-
2
]],
dtype
=
numpy
.
float32
))
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
)))
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
)))
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
sign in
to comment