Skip to content

Commit

Permalink
final iterobj updates
Browse files Browse the repository at this point in the history
  • Loading branch information
cliffckerr committed Nov 1, 2023
1 parent 426d012 commit 12c7781
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sciris/sc_nested.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def __init__(self, obj, func=None, inplace=False, copy=False, leaf=False, atomic
self._output['root'] = self.func(self.obj, *args, **kwargs)

# Check what type of object we have
self.itertype = check_iter_type(self.obj, known=self.atomic, custom=self.custom_type)
self.itertype = self.check_iter_type(self.obj)

return

Expand Down Expand Up @@ -362,14 +362,18 @@ def setitem(self, key, value):
self.custom_set(self.obj, key, value)
return

def check_iter_type(self, obj):
''' Shortcut to check_iter_type() '''
return check_iter_type(obj, known=self.atomic, custom=self.custom_type)

def iterate(self):
''' Actually perform the iteration over the object '''

# Iterate over the object
for key,subobj in self.iteritems():
trace = self._trace + [key]
newobj = subobj
subitertype = check_iter_type(subobj)
subitertype = self.check_iter_type(subobj)
self.indent(f'Working on {trace}, leaf={self.leaf}, type={str(subitertype)}')
if not (self.leaf and subitertype):
newobj = self.func(subobj, *self.func_args, **self.func_kw)
Expand Down

0 comments on commit 12c7781

Please sign in to comment.