def Minima(self, tol=None): #XXX: unique? if tol is None: tol = self.tol data = self.archive _min = max if self._inv else min _min = _min(getattr(data, 'itervalues', data.values)()) return dict((k, v) for (k, v) in getattr(data, 'iteritems', data.items)() if round(v, tol) == round(_min, tol))
def Minima(self, tol=None): #XXX: unique? """return a dict of (coordinates,values) of all discovered minima Input: tol: tolerance within which to consider a point a minima Output: a dict of (coordinates,values) of all discovered minima """ if tol is None: tol=self.tol data = self.cache _min = max if self._inv else min _min = _min(getattr(data, 'itervalues', data.values)()) return dict((k,v) for (k,v) in getattr(data, 'iteritems', data.items)() if round(v, tol) == round(_min, tol))
def from_func(cls, f, descr, prefix=None): flags = f.__code__.co_flags has_args = flags & 4 has_kws = flags & 8 if has_kws: if not has_args: raise TypeError("cannot have kwargs without args") n = 3 elif has_args: n = 2 else: n = _min(2, f.__code__.co_argcount) sig = Signature(f) r = PyMethodDef(prefix, f.__name__, f.__doc__, n, sig, descr=descr) r._func = f r._sig = sig return r
def min(*numbers): return _min(*numbers)