Skip to content

Commit

Permalink
Bug fix: changed keys() to a list in a few places to popping items in…
Browse files Browse the repository at this point in the history
… and out of the dict will work consistently
  • Loading branch information
jgostick committed Jan 23, 2015
1 parent d9fc684 commit fe2fdc7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion OpenPNM/Base/__Controller__.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def purge_object(self,obj,mode='single'):
del self[net.name]
elif mode == 'single':
name = obj.name
for item in self.keys():
for item in list(self.keys()):
# Remove label arrays from all other objects
self[item].pop('pore.'+name,None)
self[item].pop('throat.'+name,None)
Expand Down
8 changes: 6 additions & 2 deletions OpenPNM/Network/__GenericNetwork__.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,12 +747,14 @@ def trim(self, pores=[], throats=[]):
item.update({'pore.all' : sp.ones((sp.sum(Pnet),),dtype=bool)})
item.update({'throat.all' : sp.ones((sp.sum(Tnet),),dtype=bool)})
# Overwrite remaining data and info
for key in item.keys():
for key in list(item.keys()):
if key.split('.')[1] not in ['all']:
temp = item.pop(key)
if key.split('.')[0] == 'throat':
logger.debug('Trimming {a} from {b}'.format(a=key,b=item.name))
item[key] = temp[Ts]
if key.split('.')[0] == 'pore':
logger.debug('Trimming {a} from {b}'.format(a=key,b=item.name))
item[key] = temp[Ps]

#Remap throat connections
Expand All @@ -768,12 +770,14 @@ def trim(self, pores=[], throats=[]):
# Write throat connections specifically
self.update({'throat.conns' : sp.vstack((Tnew1,Tnew2)).T})
# Overwrite remaining data and info
for item in self.keys():
for item in list(self.keys()):
if item.split('.')[-1] not in ['conns','all']:
temp = self.pop(item)
if item.split('.')[0] == 'throat':
logger.debug('Trimming {a} from {b}'.format(a=item,b=self.name))
self[item] = temp[Tkeep]
if item.split('.')[0] == 'pore':
logger.debug('Trimming {a} from {b}'.format(a=item,b=self.name))
self[item] = temp[Pkeep]

#Reset network graphs
Expand Down

0 comments on commit fe2fdc7

Please sign in to comment.