Skip to content

Commit

Permalink
Add name use for factors; add __init__.py for hacky imports elsewhere.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbforbes committed Apr 29, 2016
1 parent aa5c24c commit fbf91ed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Empty file added src/__init__.py
Empty file.
5 changes: 4 additions & 1 deletion src/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,8 @@ class Factor(object):
Invariant: RVs (self._rvs), dims of potential (self._potential), and
outgoing messages (self._outgoing) must refer to the same RVs in identical
order.
NOTE: Factors DO NOT have to have unique names (RVs, however, do).
'''

def __init__(self, rvs, name='', potential=None, debug=DEBUG_DEFAULT):
Expand Down Expand Up @@ -616,7 +618,8 @@ def __init__(self, rvs, name='', potential=None, debug=DEBUG_DEFAULT):
self.set_potential(potential)

def __repr__(self):
return 'f(' + ', '.join([str(rv) for rv in self._rvs]) + ')'
name = 'f' if len(self.name) == 0 else self.name
return name + '(' + ', '.join([str(rv) for rv in self._rvs]) + ')'

def n_edges(self):
'''
Expand Down

0 comments on commit fbf91ed

Please sign in to comment.