<s> """<STR_LIT>""" <EOL> import sys <EOL> from six import string_types , iteritems <EOL> from openmdao . core . mpi_wrap import MPI <EOL> from openmdao . recorders . base_recorder import BaseRecorder <EOL> from openmdao . util . record_util import format_iteration_coordinate <EOL> class InMemoryRecorder ( BaseRecorder ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> super ( InMemoryRecorder , self ) . __init__ ( ) <EOL> self . _parallel = True <EOL> self . iters = [ ] <EOL> self . deriv_iters = [ ] <EOL> self . meta = { } <EOL> def record_iteration ( self , params , unknowns , resids , metadata ) : <EOL> """<STR_LIT>""" <EOL> data = { } <EOL> iteration_coordinate = metadata [ '<STR_LIT>' ] <EOL> data [ '<STR_LIT>' ] = metadata [ '<STR_LIT>' ] <EOL> data [ '<STR_LIT>' ] = format_iteration_coordinate ( iteration_coordinate ) <EOL> data [ '<STR_LIT:success>' ] = metadata [ '<STR_LIT:success>' ] <EOL> data [ '<STR_LIT>' ] = metadata [ '<STR_LIT>' ] <EOL> if self . options [ '<STR_LIT>' ] : <EOL> data [ '<STR_LIT>' ] = { p : v for p , v in <EOL> iteritems ( self . _filter_vector ( params , '<STR_LIT:p>' , <EOL> iteration_coordinate ) ) } <EOL> if self . options [ '<STR_LIT>' ] : <EOL> data [ '<STR_LIT>' ] = { u : v for u , v in <EOL> iteritems ( self . _filter_vector ( unknowns , '<STR_LIT:u>' , <EOL> iteration_coordinate ) ) } <EOL> if self . options [ '<STR_LIT>' ] : <EOL> data [ '<STR_LIT>' ] = { r : v for r , v in <EOL> iteritems ( self . _filter_vector ( resids , '<STR_LIT:r>' , <EOL> iteration_coordinate ) ) } <EOL> self . iters . append ( data ) <EOL> def record_metadata ( self , group ) : <EOL> """<STR_LIT>""" <EOL> self . meta [ '<STR_LIT>' ] = { n : m . copy ( ) for n , m in iteritems ( group . unknowns ) } <EOL> self . meta [ '<STR_LIT>' ] = { n : m . copy ( ) for n , m in iteritems ( group . params ) } <EOL> def record_derivatives ( self , derivs , metadata ) : <EOL> """<STR_LIT>""" <EOL> data = { } <EOL> iteration_coordinate = metadata [ '<STR_LIT>' ] <EOL> timestamp = metadata [ '<STR_LIT>' ] <EOL> data [ '<STR_LIT>' ] = timestamp <EOL> data [ '<STR_LIT>' ] = derivs <EOL> self . deriv_iters . append ( data ) </s>
