Iterate NAUTILUS method either interactively, or using given preferences if given

    Parameters
    ----------

    method : instance of NAUTILUS subclass
       Fully initialized NAUTILUS method instance
545504
def iter_nautilus(method):
    
    solution = None
    while method.current_iter:
        preference_class = init_nautilus(method)
        pref = preference_class(method, None)
        default = ",".join(map(str, pref.default_input()))
        while method.current_iter:
            method.print_current_iteration()

            pref_input = _prompt_wrapper(
                u"Preferences: ",
                default=default,
                validator=VectorValidator(method, pref),
            )

            cmd = _check_cmd(pref_input)
            if cmd:
                solution = method.zh
                break
            pref = preference_class(
                method, np.fromstring(pref_input, dtype=np.float, sep=",")
            )
            default = ",".join(map(str, pref.pref_input))
            solution, _ = method.next_iteration(pref)
        if cmd and list(cmd)[0] == "c":
            break
    return solution
1346402
def bound_rewritable_methods(self, methods):
        
        for key, value in methods.items():
            if key in self.REWRITABLE_METHODS:
                setattr(self, key, types.MethodType(value, self))
16851
def api_method(f):
    '''
    
    '''

    @wraps(f)
    def wrapped(*args, **kwargs):
        # Get the instance and call the method
        algorithm = get_context()
        if algorithm is None:
            raise RuntimeError(
                '{} method must be called during live trading'.format(
                    f.__name__))
        return getattr(algorithm, f.__name__)(*args, **kwargs)

    # register api redirection
    setattr(pylivetrader.api, f.__name__, wrapped)
    pylivetrader.api.__all__.append(f.__name__)
    f.is_api_method = True

    return f
1119754
private void callHandleMethod(Method method, Object instance, 
            Object roomAgent, Object userAgent) {
        ReflectMethodUtil.invokeHandleMethod(method, 
                    instance, context, roomAgent, userAgent);
    }
455465
def methods(self, methods):
        """"""
        # We make sure that the dictionary is a NocaseDict object, and that the
        # property values are CIMMethod objects:
        # pylint: disable=attribute-defined-outside-init
        self._methods = NocaseDict()
        if methods:
            try:
                # This is used for iterables:
                iterator = methods.items()
            except AttributeError:
                # This is used for dictionaries:
                iterator = methods
            for item in iterator:
                if isinstance(item, CIMMethod):
                    key = item.name
                    value = item
                elif isinstance(item, tuple):
                    key, value = item
                else:
                    raise TypeError(
                        _format("Input object for methods has invalid item in "
                                "iterable: {0!A}", item))
                self.methods[key] = _cim_method(key, value)
711917
public static MethodParameters of(Method method) {

		Assert.notNull(method, "Method must not be null!");

		return CACHE.computeIfAbsent(method, MethodParameters::new);
	}
953748
private void handleMainMethodIfPresent(List methods) {
        boolean found = false;
        for (Iterator iter = methods.iterator(); iter.hasNext();) {
            MethodNode node = (MethodNode) iter.next();
            if(node.getName().equals("main")) {
                if (node.isStatic() && node.getParameters().length == 1) {
                    boolean retTypeMatches, argTypeMatches;
                    ClassNode argType = node.getParameters()[0].getType();
                    ClassNode retType = node.getReturnType();

                    argTypeMatches = (argType.equals(ClassHelper.OBJECT_TYPE) || argType.getName().contains("String[]"));
                    retTypeMatches = (retType == ClassHelper.VOID_TYPE || retType == ClassHelper.OBJECT_TYPE);
                    
                    if(retTypeMatches && argTypeMatches) {
                        if(found) {
                            throw new RuntimeException("Repetitive main method found.");
                        } else {
                            found = true;
                        }
                        // if script has both loose statements as well as main(), then main() is ignored
                        if(statementBlock.isEmpty()) {
                            addStatement(node.getCode());
                        }
                        iter.remove();
                    }
                }
            }
        }
    }
1146237
function initMethod(method, id) {

    function getNamespace(type) {
      return type.split('.').reduce(function(ns, name) {
        if (!ns[name]) {
          // Create missing namespaces.
          ns[name] = {};
        }
        return ns[name];
      }, global);
    }

    function canNotify(self, args) {
      var wasNotified = method.message in encountered, check;
      check = (!method.suppressed) &&
              (!optionUnique() || !wasNotified) &&
              (!method.check || method.check.apply(self, args));
      if (check) {
        encountered[method.message] = true;
      }
      return check;
    }

    function wrapMethod(target, name) {
      var fn = target[name];
      function withSugarNotification() {
        var message = method.message, result;

        function exec(self, args) {
          if (!fn) {
            var targetName = method.type + (self === target ? '' : '.prototype');
            throw new Error(['Method', name, 'does not exist on', targetName].join(' '));
          }
          return fn.apply(self, args);
        }

        if (method.call) {
          message = message.replace(/%.+%/g, method.call.apply(this, arguments));
        }

        if (!isNotifying && canNotify(this, arguments, id)) {
          // Preventing nested notifications means that we don't have to
          // worry about detecting Sugar in the call stack as any call other
          // than the main entry point must be Sugar calling itself.
          if (fn && fn.name !== 'withSugarNotification') {
            // Prevent internal Sugar calls from triggering notifications,
            // but only if methods are not multi-wrapped.
            isNotifying = true;
          }
          notify(message, method);
          result = exec(this, arguments);
          isNotifying = false;
          return result;
        }
        return exec(this, arguments);
      }
      if (method.check === 'missing') {
        if (fn) {
          method.check = function() {
            return false;
          };
        } else {
          delete method.check;
        }
      }
      target[name] = withSugarNotification;
    }

    function wrapProp(target) {
      var val = target[method.prop];
      Object.defineProperty(target, method.prop, {
        get: function() {
          notify(method.message, method);
          return val;
        },
        set: function(newVal) {
          notify(method.message, method);
          val = newVal;
        }
      });
    }

    var ns = getNamespace(method.type);

    if (method.sName) {
      method.sName.split(',').forEach(function(name) {
        wrapMethod(ns, name);
      });
    }
    if (method.iName) {
      method.iName.split(',').forEach(function(name) {
        wrapMethod(ns.prototype, name);
      });
    }
    if (method.prop && DEFINE_PROPERTY_SUPPORT) {
      wrapProp(ns);
    }

    method.clean = method.message.replace(/%/g, '');
    method.id = id;
    method.pid = pad(id, 2, true);
  }
1149446
def map(self, method: str, *args, _threaded: bool = True, **kwargs
           ) -> "AttrIndexedDict":
        ""

        work = lambda item: getattr(item, method)(*args, **kwargs)

        if _threaded:
            pool = ThreadPool(int(config.CFG["GENERAL"]["parallel_requests"]))

            try:
                pool.map(work, self.data.values())
            except KeyboardInterrupt:
                LOG.warning("CTRL-C caught, finishing current tasks...")
                pool.terminate()
            else:
                pool.close()

            pool.join()
            return self

        for item in self.data.values():
            work(item)
        return self
532488
public void invokestatic(ExecutableElement method) throws IOException
    {
        int index = subClass.resolveMethodIndex(method);
        invokestatic(index);
    }
1134455
def initialize_public_method(method, parent)
      return if !method || !parent

      new_meth = AnyMethod.new("External Alias for module", method.name)
      new_meth.singleton    = method.singleton
      new_meth.params       = method.params.clone
      new_meth.comment      = remove_trailing_alias(method.comment.clone)
      new_meth.comment      << "\n\n#{EXTERNAL_ALIAS_MES} #{parent.strip.chomp}\##{method.name}"

      return new_meth
    end
392293
public static <T> T invoke(Object instance, String method, Object... args) {
        if (instance == null) return null;
        try {
            Method m = getPublicMethod(instance.getClass(), method, getArgsClasses(args));
            return (T) m.invoke(instance, args);
        } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
            throw new IllegalStateException(e.getMessage(), e);
        }
    }
1085386
private void invoke(Method method, Object instance, Object[] params) throws SlickXMLException {
		try {
			method.setAccessible(true);
			method.invoke(instance, params);
		} catch (IllegalArgumentException e) {
			throw new SlickXMLException("Failed to invoke: "+method+" for an XML attribute, is it valid?", e);
		} catch (IllegalAccessException e) {
			throw new SlickXMLException("Failed to invoke: "+method+" for an XML attribute, is it valid?", e);
		} catch (InvocationTargetException e) {
			throw new SlickXMLException("Failed to invoke: "+method+" for an XML attribute, is it valid?", e);
		} finally {
			method.setAccessible(false);
		}
	}
836307
private synchronized void setInitializationMethod(Method newMethod)
    {
        if (newMethod != null)
        {
            // make sure it's a no argument method
            if (newMethod.getParameterTypes().length > 0)
            {
                throw new MetadataException(
                    "Initialization methods must be zero argument methods: "
                        + newMethod.getClass().getName()
                        + "."
                        + newMethod.getName());
            }

            // make it accessible if it's not already
            if (!newMethod.isAccessible())
            {
                newMethod.setAccessible(true);
            }
        }
        this.initializationMethod = newMethod;
    }
716853
public void addNewStaticMethod(Method method) {
        final CachedMethod cachedMethod = CachedMethod.find(method);
        NewStaticMetaMethod newMethod = new NewStaticMetaMethod(cachedMethod);
        final CachedClass declaringClass = newMethod.getDeclaringClass();
        addNewStaticMethodToIndex(newMethod, metaMethodIndex.getHeader(declaringClass.getTheClass()));
    }
730198
public static MethodHandle defaultInvoker( Method method )
    {
        if ( !method.isDefault() )
        {
            throw new IllegalArgumentException( "Not a default method: " + method );
        }
        try
        {
            return LOOKUP.unreflectSpecial( method, method.getDeclaringClass() );
        }
        catch ( IllegalAccessException e )
        {
            throw new RuntimeException( "Reflection failed.", e );
        }
    }
825894
private function runInitMethods(): void
    {
        $reflectionClass = self::getDoctrineStaticMeta()->getReflectionClass();
        $methods         = $reflectionClass->getMethods(\ReflectionMethod::IS_PRIVATE);
        foreach ($methods as $method) {
            if ($method instanceof ReflectionMethod) {
                $method = $method->getName();
            }
            if (\ts\stringContains($method, UsesPHPMetaDataInterface::METHOD_PREFIX_INIT)
                && \ts\stringStartsWith($method, UsesPHPMetaDataInterface::METHOD_PREFIX_INIT)
            ) {
                $this->$method();
            }
        }
    }