Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
PRIMO
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Looking for advice? Join the
Matrix channel for GitLab users in Bielefeld
!
Show more breadcrumbs
Social Cognitive Systems
PRIMO
Commits
1ef19faa
Commit
1ef19faa
authored
12 years ago
by
mbaumBielefeld
Browse files
Options
Downloads
Patches
Plain Diff
Added BayesNet_test
parent
362459a9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/BayesNet.py
+7
-2
7 additions, 2 deletions
core/BayesNet.py
core/tests/BayesNet_test.py
+32
-0
32 additions, 0 deletions
core/tests/BayesNet_test.py
with
39 additions
and
2 deletions
core/BayesNet.py
+
7
−
2
View file @
1ef19faa
...
...
@@ -47,8 +47,13 @@ class BayesNet(object):
raise
Exception
(
"
There is no node with name
"
+
node_name
+
"
in the bayesnet
"
)
def
get_nodes
(
self
,
node_names
):
for
node_name
in
node_names
:
yield
self
.
get_node
(
node_name
)
nodes
=
[]
if
not
node_names
:
nodes
=
self
.
bn
.
nodes
()
else
:
for
node_name
in
node_names
:
nodes
.
append
(
self
.
get_node
(
node_name
))
return
nodes
def
get_parents
(
self
,
node
):
raise
Exception
(
"
Called unimplemented function
"
)
...
...
This diff is collapsed.
Click to expand it.
core/tests/BayesNet_test.py
0 → 100644
+
32
−
0
View file @
1ef19faa
import
unittest
from
core.BayesNet
import
BayesNet
from
core.Node
import
Node
class
NodeAddAndRemoveTestCase
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
bn
=
BayesNet
()
def
tearDown
(
self
):
self
.
bn
=
None
def
test_add
(
self
):
n
=
Node
(
"
Some Node
"
)
self
.
bn
.
add_node
(
n
)
self
.
assertEqual
(
n
,
self
.
bn
.
get_node
(
"
Some Node
"
))
self
.
assertTrue
(
n
in
self
.
bn
.
get_nodes
([
"
Some Node
"
]))
node_with_same_name
=
Node
(
"
Some Node
"
)
self
.
assertRaises
(
Exception
,
self
.
bn
.
add_node
,
node_with_same_name
)
def
test_remove
(
self
):
n
=
Node
(
"
Some Node to remove
"
)
self
.
bn
.
add_node
(
n
)
self
.
bn
.
remove_node
(
n
)
self
.
assertFalse
(
n
in
self
.
bn
.
get_nodes
())
#include this so you can run this test without nose
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