def __init__(self, exprs=(), derivatives=(), sleep=0, dsleep=0):
        super(ExecCompWithDerivatives, self).__init__()
        
        outs = set()
        allvars = set()
        self.exprs = exprs
        self.codes = [compile(expr,'<string>','exec') for expr in exprs]
        self.sleep = sleep
        self.dsleep = dsleep
        
        for expr in exprs:
            lhs,rhs = expr.split('=')
            lhs = lhs.strip()
            lhs = lhs.split(',')
            outs.update(lhs)
            expreval = ExprEvaluator(expr, scope=self)
            allvars.update(expreval.get_referenced_varpaths(copy=False))
        
        for var in allvars:
            if '.' not in var:  # if a varname has dots, it's outside of our scope,
                                # so don't add a trait for it
                if var in outs:
                    iotype = 'out'
                else:
                    iotype = 'in'
                self.add(var, Float(0.0, iotype=iotype))
    
        self.deriv_exprs = derivatives
        self.derivative_codes = \
            [compile(expr,'<string>','exec') for expr in derivatives]
        
        self.derivative_names = []
        regex = re.compile('d(.*)_d(.*)')
        for expr in derivatives:
            expreval = ExprEvaluator(expr, scope=self)
            exvars = expreval.get_referenced_varpaths(copy=False)
            
            lhs, _ = expr.split('=')
            lhs = lhs.strip()
            allvars.add(lhs)
            
            # Check for undefined vars the cool way with sets
            if len(exvars-allvars) > 0:
                self.raise_exception('derivative references a variable '
                                     'that is not defined in exprs',
                                     ValueError)
                    
            names = regex.findall(lhs)
            num = names[0][0]
            wrt = names[0][1]
            
            self.derivative_names.append( (lhs, num, wrt) )
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.test/src/openmdao/test/execcomp.py/ExecCompWithDerivatives.__init__/original