<s> """<STR_LIT>""" <EOL> from openmdao . drivers . predeterminedruns_driver import PredeterminedRunsDriver <EOL> from six import moves , iteritems <EOL> import numpy as np <EOL> class UniformDriver ( PredeterminedRunsDriver ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , num_samples = <NUM_LIT:1> , seed = None , num_par_doe = <NUM_LIT:1> , load_balance = False ) : <EOL> super ( UniformDriver , self ) . __init__ ( num_par_doe = num_par_doe , <EOL> load_balance = load_balance ) <EOL> self . num_samples = num_samples <EOL> self . seed = seed <EOL> def _build_runlist ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . seed is not None : <EOL> np . random . seed ( self . seed ) <EOL> for i in moves . range ( self . num_samples ) : <EOL> sample = [ ] <EOL> for key , meta in iteritems ( self . get_desvar_metadata ( ) ) : <EOL> nval = meta [ '<STR_LIT:size>' ] <EOL> values = [ ] <EOL> for k in range ( nval ) : <EOL> low = meta [ '<STR_LIT>' ] <EOL> high = meta [ '<STR_LIT>' ] <EOL> if isinstance ( low , np . ndarray ) : <EOL> low = low [ k ] <EOL> if isinstance ( high , np . ndarray ) : <EOL> high = high [ k ] <EOL> values . append ( np . random . uniform ( low , high ) ) <EOL> sample . append ( [ key , np . array ( values ) ] ) <EOL> yield sample </s>
