Skip to content

Commit

Permalink
- Core.network() now works like all the lookup methods, returning a l…
Browse files Browse the repository at this point in the history
…ist or a handle to the named object

- network._net now returns a handle to itself, similar to how obj._net returned a handled to the Network.
  • Loading branch information
jgostick committed Jan 26, 2015
1 parent d32b02a commit 06ea340
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
16 changes: 7 additions & 9 deletions OpenPNM/Base/__Core__.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,30 +290,28 @@ def geometries(self,geom_name=[]):
def network(self,name=''):
r'''
Retrieves the network associated with the object. If the object is
a network, then it returns the parent network from which the present
object derives, or returns an empty list if it has no parents.
a network, then it returns a handle to itself.
Parameters
----------
name : string, optional
The name of the Geometry object to retrieve.
The name of the Network object to retrieve.
Returns
-------
If name is NOT provided, then the name of the parent is returned.
If a name IS provided, then the parent netowrk object is returned.
Notes
-----
This doesn't quite work yet...we have to decide how to treat sub-nets first
'''
if name == '':
try:
net = self._net.name
except:
net = []
if self._net is None:
net = [self]
else:
net = [self._net]
else:
net = self._net
net = self._find_object(obj_name=name)
return net

#--------------------------------------------------------------------------
Expand Down
8 changes: 7 additions & 1 deletion OpenPNM/Network/__GenericNetwork__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ def __getitem__(self,key):
return self._interleave_data(key,self.geometries())
else:
return super(GenericNetwork,self).__getitem__(key)


def _set_net(self,network):
pass
def _get_net(self):
return self
_net = property(fset=_set_net,fget=_get_net)

#--------------------------------------------------------------------------
'''Graph Theory and Network Query Methods'''
#--------------------------------------------------------------------------
Expand Down

0 comments on commit 06ea340

Please sign in to comment.