Initialize the simulation. Organize calculations by dependency.

        :param calc_reg: Calculation registry.
        :type calc_reg:
            :class:`~simkit.core.calculation.CalcRegistry`
962903
def initialize(self, calc_reg):
        
        self._isinitialized = True
        # TODO: if calculations are edited, loaded, added, etc. then reset
        self.calc_order = topological_sort(calc_reg.dependencies)
781517
def get_std_registry():
    
    from six import itervalues
    reg = Registry()
    for fn in itervalues(builtin_registrars):
        fn(reg)
    return reg
659662
def register_scheme(scheme, constructor):
        
        if not re.search(r'^[a-z]+$', scheme):
            raise ValueError('{0!s} is not a valid scheme'.format(scheme))

        if scheme in SimpleConditionFactory._constructors:
            raise ValueError('Scheme {0!s} is registered already'.format(scheme))

        SimpleConditionFactory._constructors[scheme] = constructor
1265810
def register(name, _callable=None):
    
    def wrapper(_callable):
        registered_checks[name] = _callable
        return _callable

    # If function or class is given, do the registeration
    if _callable:
        return wrapper(_callable)

    return wrapper
804284
def registry(attr, base=type):
    """"""
    class Registry(base):
        def __init__(cls, name, bases, attrs):
            super(Registry, cls).__init__(name, bases, attrs)
            if not hasattr(cls, '__registry__'):
                cls.__registry__ = {}
            key = getattr(cls, attr)
            if key is not NotImplemented:
                assert key not in cls.__registry__
                cls.__registry__[key] = cls
        def __dispatch__(cls, key):
            try:
                return cls.__registry__[key]
            except KeyError:
                raise ValueError('Unknown %s: %s' % (attr, key))
    return Registry
231404
def add_new_init_method(cls):
    

    orig_init = cls.__init__

    def new_init(self, *args, **kwargs):
        self._dependent_generators = []
        orig_init(self, *args, **kwargs)

    cls.__init__ = new_init
1064647
public static synchronized void initialise()
   {
      // Only initialise if it has not already been created
      if (_instance == null)
      {
         // Check what environment we are running in. If we are in server mode we must use the 
         // server diagnostic module.
    	 //Liberty COMMS TODO:
    	 //For now not enabling server side diagnostics as can not load SERVER_DIAG_MODULE_CLASS in a clean manner
    	 // without having dependency of COMMs server ( at least more than 4/5 classes are needed) which defeat
    	 // the purpose of COMMS client independence w.r.to COMMS server
    	 //Has to rework on load SERVER_DIAG_MODULE_CLASS without too many dependencies of COMMS server.
    	
    	 /*
         if (RuntimeInfo.isServer())
         {
            if (tc.isDebugEnabled()) SibTr.debug(tc, "We are in Server mode");
            
            try
            {
               Class clazz = Class.forName(CommsConstants.SERVER_DIAG_MODULE_CLASS);
               Method getInstanceMethod = clazz.getMethod("getInstance", new Class[0]);
               _instance = (CommsDiagnosticModule) getInstanceMethod.invoke(null, (Object[]) null);
            }
            catch (Exception e)
            {
               FFDCFilter.processException(e, CLASS_NAME + ".initialise", 
                                           CommsConstants.COMMSDIAGMODULE_INITIALIZE_01,
                                           CommsConstants.SERVER_DIAG_MODULE_CLASS);
               
               if (tc.isDebugEnabled()) SibTr.debug(tc, "Unable to load the Comms Server Diagnostic Module", e);
               
               // In this case, fall out of here with a null _instance and default to the client
               // one. At least in that case we get _some_ diagnostics...
               // This is the point where I mention that that shouldn't ever happen :-).
            }
         }
         */

         // In all other cases use the client diagnostic module. Note we can instantiate this
         // directly as we are located in the same build component
         if (_instance == null)
         {
            if (tc.isDebugEnabled()) SibTr.debug(tc, "We are NOT in Server mode");
            
            _instance = ClientCommsDiagnosticModule.getInstance();
         }
         
         // Now register the packages
         _instance.register(packageList);
      }
   }
841293
def register_get(self, regex, callback):
        
        if callback is None:                                                                    # pragma: no cover
            if regex in self.get_registrations:
                del self.get_registrations[regex]
        else:
            self.get_registrations[regex] = (re.compile(regex), callback)
121473
def _register(self, cls):
        
        if not inspect.isclass(cls):
            raise ValueError('Only classes may be registered.')
        elif not issubclass(cls, self._registerable_class):
            raise ValueError('Only %s classes or subclasses may be registered.'
                             % self._registerable_class.__name__)

        if cls not in self._registry:
            cls._registered_with = self
            self._registry[cls] = cls()

        return self._registry[cls]
590690
def setOrderedRegisterNumbers(order, start):
    
    for i, node in enumerate(order):
        node.reg.n = start + i
    return start + len(order)
1015451
def register(cls):
    
    definition_name = make_definition_name(cls.__name__)
    REGISTRY[definition_name] = cls
    return cls
81984
def _compute_register_list(self, operand):
        

        ret = []
        for reg_range in operand.reg_list:
            if len(reg_range) == 1:
                ret.append(ReilRegisterOperand(reg_range[0].name, reg_range[0].size))
            else:
                reg_num = int(reg_range[0].name[1:])    # Assuming the register is named with one letter + number
                reg_end = int(reg_range[1].name[1:])
                if reg_num > reg_end:
                    raise NotImplementedError("Instruction Not Implemented: Invalid register range.")
                while reg_num <= reg_end:
                    ret.append(ReilRegisterOperand(reg_range[0].name[0] + str(reg_num), reg_range[0].size))
                    reg_num = reg_num + 1

        return ret
1332622
def _set_reg(cls, reg):
        
        cls._reg = [task_cls for task_cls in reg.values() if task_cls is not cls.AMBIGUOUS_CLASS]
994290
public function init()
    {
        if (! empty($this->registry[$this->section])) {
            throw new RegistryException(
                RegistryException::DUPLICATE_INITIATION_ATTEMPT_TEXT . '(section: ' . $this->section . ')',
                RegistryException::DUPLICATE_INITIATION_ATTEMPT_CODE
            );
        }

        $this->registry[$this->section] = array();
    }
747910
def _do_register(cls, code, name, hash_name=None, hash_new=None):
        """"""
        cls._func_from_name[name.replace('-', '_')] = code
        cls._func_from_name[name.replace('_', '-')] = code
        if hash_name:
            cls._func_from_hash[hash_name] = code
        cls._func_hash[code] = cls._hash(hash_name, hash_new)
237703
private void initialize() {
    LocaleUtils localeUtils = new LocaleUtils();
    String language = localeUtils.inferDeviceLanguage(getContext());
    String unitType = localeUtils.getUnitTypeForDeviceLocale(getContext());
    int roundingIncrement = NavigationConstants.ROUNDING_INCREMENT_FIFTY;
    distanceFormatter = new DistanceFormatter(getContext(), language, unitType, roundingIncrement);
    inflate(getContext(), R.layout.instruction_view_layout, this);
  }
576864
def register(cls, instance_class, name=None):
        
        if name is None:
            name = instance_class.__name__
        cls.INSTANCE_CLASSES[name] = instance_class