openmdao/core/group.py
def add_subsystem(self, name, subsys, promotes=None,
                      promotes_inputs=None, promotes_outputs=None,
                      min_procs=1, max_procs=None, proc_weight=1.0):
        """
        Add a subsystem.

        Parameters
        ----------
        name : str
            Name of the subsystem being added
        subsys : <System>
            An instantiated, but not-yet-set up system object.
        promotes : iter of (str or tuple), optional
            A list of variable names specifying which subsystem variables
            to 'promote' up to this group. If an entry is a tuple of the
            form (old_name, new_name), this will rename the variable in
            the parent group.
        promotes_inputs : iter of (str or tuple), optional
            A list of input variable names specifying which subsystem input
            variables to 'promote' up to this group. If an entry is a tuple of
            the form (old_name, new_name), this will rename the variable in
            the parent group.
        promotes_outputs : iter of (str or tuple), optional
            A list of output variable names specifying which subsystem output
            variables to 'promote' up to this group. If an entry is a tuple of
            the form (old_name, new_name), this will rename the variable in
            the parent group.
        min_procs : int
            Minimum number of MPI processes usable by the subsystem. Defaults to 1.
        max_procs : int or None
            Maximum number of MPI processes usable by the subsystem.  A value
            of None (the default) indicates there is no maximum limit.
        proc_weight : float
            Weight given to the subsystem when allocating available MPI processes
            to all subsystems.  Default is 1.0.

        Returns
        -------
        <System>
            the subsystem that was passed in. This is returned to
            enable users to instantiate and add a subsystem at the
            same time, and get the reference back.
        """
        if inspect.isclass(subsys):
            raise TypeError("Subsystem '%s' should be an instance, "
                            "but a class object was found." % name)

        for sub in chain(self._subsystems_allprocs,
                         self._static_subsystems_allprocs):
            if name == sub.name:
                raise RuntimeError("Subsystem name '%s' is already used." %
                                   name)

        if hasattr(self, name) and not isinstance(getattr(self, name), System):
            # replacing a subsystem is ok (e.g. resetup) but no other attribute
            raise RuntimeError("Group '%s' already has an attribute '%s'." %
                               (self.name, name))

        match = namecheck_rgx.match(name)
        if match is None or match.group() != name:
            raise NameError("'%s' is not a valid system name." % name)

        subsys.name = subsys.pathname = name

        if isinstance(promotes, string_types) or \
           isinstance(promotes_inputs, string_types) or \
           isinstance(promotes_outputs, string_types):
                raise RuntimeError("%s: promotes"
                                   " must be an iterator of strings and/or tuples." %
                                   self.name)
        if promotes:
            subsys._var_promotes['any'] = promotes
        if promotes_inputs:
            subsys._var_promotes['input'] = promotes_inputs
        if promotes_outputs:
            subsys._var_promotes['output'] = promotes_outputs

        if self._static_mode:
            subsystems_allprocs = self._static_subsystems_allprocs
        else:
            subsystems_allprocs = self._subsystems_allprocs

        subsystems_allprocs.append(subsys)

        if not isinstance(min_procs, int) or min_procs < 1:
            raise TypeError("%s: min_procs must be an int > 0 but (%s) was given." %
                            (self.name, min_procs))
        if max_procs is not None and (not isinstance(max_procs, int) or max_procs < min_procs):
            raise TypeError("%s: max_procs must be None or an int >= min_procs but (%s) was given."
                            % (self.name, max_procs))
        if isinstance(proc_weight, Number) and proc_weight < 0:
            raise TypeError("%s: proc_weight must be a float > 0. but (%s) was given." %
                            (self.name, proc_weight))

        self._proc_info[name] = (min_procs, max_procs, proc_weight)

        setattr(self, name, subsys)

        return subsys

        Add a subsystem.

        Parameters
        ----------
        name : str
            Name of the subsystem being added
        subsys : <System>
            An instantiated, but not-yet-set up system object.
        promotes : iter of (str or tuple), optional
            A list of variable names specifying which subsystem variables
            to 'promote' up to this group. If an entry is a tuple of the
            form (old_name, new_name), this will rename the variable in
            the parent group.
        promotes_inputs : iter of (str or tuple), optional
            A list of input variable names specifying which subsystem input
            variables to 'promote' up to this group. If an entry is a tuple of
            the form (old_name, new_name), this will rename the variable in
            the parent group.
        promotes_outputs : iter of (str or tuple), optional
            A list of output variable names specifying which subsystem output
            variables to 'promote' up to this group. If an entry is a tuple of
            the form (old_name, new_name), this will rename the variable in
            the parent group.
        min_procs : int
            Minimum number of MPI processes usable by the subsystem. Defaults to 1.
        max_procs : int or None
            Maximum number of MPI processes usable by the subsystem.  A value
            of None (the default) indicates there is no maximum limit.
        proc_weight : float
            Weight given to the subsystem when allocating available MPI processes
            to all subsystems.  Default is 1.0.

        Returns
        -------
        <System>
            the subsystem that was passed in. This is returned to
            enable users to instantiate and add a subsystem at the
            same time, and get the reference back.
        
Add a subsystem.
Parameters

name : str
Name of the subsystem being added
subsys : 
An instantiated, but not-yet-set up system object.
promotes : iter of (str or tuple), optional
A list of variable names specifying which subsystem variables
to 'promote' up to this group. If an entry is a tuple of the
form (old_name, new_name), this will rename the variable in
the parent group.
promotes_inputs : iter of (str or tuple), optional
A list of input variable names specifying which subsystem input
variables to 'promote' up to this group. If an entry is a tuple of
the form (old_name, new_name), this will rename the variable in
the parent group.
promotes_outputs : iter of (str or tuple), optional
A list of output variable names specifying which subsystem output
variables to 'promote' up to this group. If an entry is a tuple of
the form (old_name, new_name), this will rename the variable in
the parent group.
min_procs : int
Minimum number of MPI processes usable by the subsystem. Defaults to 1.
max_procs : int or None
Maximum number of MPI processes usable by the subsystem.  A value
of None (the default) indicates there is no maximum limit.
proc_weight : float
Weight given to the subsystem when allocating available MPI processes
to all subsystems.

Returns


the subsystem that was passed in. This is returned to
enable users to instantiate and add a subsystem at the
same time, and get the reference back.
Add a subsystem . Parameters name : str Name of the subsystem being added subsys : An instantiated but not - yet - set up system object . promotes : iter of ( str or tuple ) optional A list of variable names specifying which subsystem variables to ' promote ' up to this group . If an entry is a tuple of the form ( old_name new_name ) this will rename the variable in the parent group . promotes_inputs : iter of ( str or tuple ) optional A list of input variable names specifying which subsystem input variables to ' promote ' up to this group . If an entry is a tuple of the form ( old_name new_name ) this will rename the variable in the parent group . promotes_outputs : iter of ( str or tuple ) optional A list of output variable names specifying which subsystem output variables to ' promote ' up to this group . If an entry is a tuple of the form ( old_name new_name ) this will rename the variable in the parent group . min_procs : int Minimum number of MPI processes usable by the subsystem . Defaults to 1 . max_procs : int or None Maximum number of MPI processes usable by the subsystem . A value of None ( the default ) indicates there is no maximum limit . proc_weight : float Weight given to the subsystem when allocating available MPI processes to all subsystems . Returns the subsystem that was passed in . This is returned to enable users to instantiate and add a subsystem at the same time and get the reference back .
def add_subsystem(self, name, subsys, promotes=None,
                      promotes_inputs=None, promotes_outputs=None,
                      min_procs=1, max_procs=None, proc_weight=1.0):
        if inspect.isclass(subsys):
            raise TypeError("Subsystem '%s' should be an instance, "
                            "but a class object was found." % name)
        for sub in chain(self._subsystems_allprocs,
                         self._static_subsystems_allprocs):
            if name == sub.name:
                raise RuntimeError("Subsystem name '%s' is already used." %
                                   name)
        if hasattr(self, name) and not isinstance(getattr(self, name), System):
            raise RuntimeError("Group '%s' already has an attribute '%s'." %
                               (self.name, name))
        match = namecheck_rgx.match(name)
        if match is None or match.group() != name:
            raise NameError("'%s' is not a valid system name." % name)
        subsys.name = subsys.pathname = name
        if isinstance(promotes, string_types) or \
           isinstance(promotes_inputs, string_types) or \
           isinstance(promotes_outputs, string_types):
                raise RuntimeError("%s: promotes"
                                   " must be an iterator of strings and/or tuples." %
                                   self.name)
        if promotes:
            subsys._var_promotes['any'] = promotes
        if promotes_inputs:
            subsys._var_promotes['input'] = promotes_inputs
        if promotes_outputs:
            subsys._var_promotes['output'] = promotes_outputs
        if self._static_mode:
            subsystems_allprocs = self._static_subsystems_allprocs
        else:
            subsystems_allprocs = self._subsystems_allprocs
        subsystems_allprocs.append(subsys)
        if not isinstance(min_procs, int) or min_procs < 1:
            raise TypeError("%s: min_procs must be an int > 0 but (%s) was given." %
                            (self.name, min_procs))
        if max_procs is not None and (not isinstance(max_procs, int) or max_procs < min_procs):
            raise TypeError("%s: max_procs must be None or an int >= min_procs but (%s) was given."
                            % (self.name, max_procs))
        if isinstance(proc_weight, Number) and proc_weight < 0:
            raise TypeError("%s: proc_weight must be a float > 0. but (%s) was given." %
                            (self.name, proc_weight))
        self._proc_info[name] = (min_procs, max_procs, proc_weight)
        setattr(self, name, subsys)
        return subsys
def add_subsystem ( self , name , subsys , promotes = None , promotes_inputs = None , promotes_outputs = None , min_procs = 1 , max_procs = None , proc_weight = 1.0 ) : if inspect . isclass ( subsys ) : raise TypeError ( "Subsystem '%s' should be an instance, " "but a class object was found." % name ) for sub in chain ( self . _subsystems_allprocs , self . _static_subsystems_allprocs ) : if name == sub . name : raise RuntimeError ( "Subsystem name '%s' is already used." % name ) if hasattr ( self , name ) and not isinstance ( getattr ( self , name ) , System ) : raise RuntimeError ( "Group '%s' already has an attribute '%s'." % ( self . name , name ) ) match = namecheck_rgx . match ( name ) if match is None or match . group ( ) != name : raise NameError ( "'%s' is not a valid system name." % name ) subsys . name = subsys . pathname = name if isinstance ( promotes , string_types ) or isinstance ( promotes_inputs , string_types ) or isinstance ( promotes_outputs , string_types ) : raise RuntimeError ( "%s: promotes" " must be an iterator of strings and/or tuples." % self . name ) if promotes : subsys . _var_promotes [ 'any' ] = promotes if promotes_inputs : subsys . _var_promotes [ 'input' ] = promotes_inputs if promotes_outputs : subsys . _var_promotes [ 'output' ] = promotes_outputs if self . _static_mode : subsystems_allprocs = self . _static_subsystems_allprocs else : subsystems_allprocs = self . _subsystems_allprocs subsystems_allprocs . append ( subsys ) if not isinstance ( min_procs , int ) or min_procs < 1 : raise TypeError ( "%s: min_procs must be an int > 0 but (%s) was given." % ( self . name , min_procs ) ) if max_procs is not None and ( not isinstance ( max_procs , int ) or max_procs < min_procs ) : raise TypeError ( "%s: max_procs must be None or an int >= min_procs but (%s) was given." % ( self . name , max_procs ) ) if isinstance ( proc_weight , Number ) and proc_weight < 0 : raise TypeError ( "%s: proc_weight must be a float > 0. but (%s) was given." % ( self . name , proc_weight ) ) self . _proc_info [ name ] = ( min_procs , max_procs , proc_weight ) setattr ( self , name , subsys ) return subsys
Add a subsystem.
Add a subsystem .
"""
        Add a subsystem.

        Parameters
        ----------
        name : str
            Name of the subsystem being added
        subsys : <System>
            An instantiated, but not-yet-set up system object.
        promotes : iter of (str or tuple), optional
            A list of variable names specifying which subsystem variables
            to 'promote' up to this group. If an entry is a tuple of the
            form (old_name, new_name), this will rename the variable in
            the parent group.
        promotes_inputs : iter of (str or tuple), optional
            A list of input variable names specifying which subsystem input
            variables to 'promote' up to this group. If an entry is a tuple of
            the form (old_name, new_name), this will rename the variable in
            the parent group.
        promotes_outputs : iter of (str or tuple), optional
            A list of output variable names specifying which subsystem output
            variables to 'promote' up to this group. If an entry is a tuple of
            the form (old_name, new_name), this will rename the variable in
            the parent group.
        min_procs : int
            Minimum number of MPI processes usable by the subsystem. Defaults to 1.
        max_procs : int or None
            Maximum number of MPI processes usable by the subsystem.  A value
            of None (the default) indicates there is no maximum limit.
        proc_weight : float
            Weight given to the subsystem when allocating available MPI processes
            to all subsystems.  Default is 1.0.

        Returns
        -------
        <System>
            the subsystem that was passed in. This is returned to
            enable users to instantiate and add a subsystem at the
            same time, and get the reference back.
        """ # replacing a subsystem is ok (e.g. resetup) but no other attribute
self
name
subsys
promotes
promotes_inputs
promotes_outputs
min_procs
max_procs
proc_weight