utils Package¶
stop_criteria Module¶
Created on Mar 4, 2014
author: jakeret
-
class
ivy.utils.stop_criteria.RangeStopCriteria(maxIter)[source]¶ Bases:
ivy.utils.stop_criteria.StopCriteriaStopping criteria which stops after maxIter iterations
-
class
ivy.utils.stop_criteria.SimpleStopCriteria[source]¶ Bases:
ivy.utils.stop_criteria.RangeStopCriteriaSimple implementation of a stopping criteria. Stops after one iteration
struct Module¶
Created on Mar 4, 2014
author: jakeret
-
class
ivy.utils.struct.ImmutableStruct(initializer=None, **extra_args)[source]¶ Bases:
ivy.utils.struct._BaseA dict-like object, whose keys can be accessed with the usual ‘[…]’ lookup syntax, or with the ‘.’ get attribute syntax.
Examples:
>>> a = Struct() >>> a['x'] = 1 >>> a.x 1 >>> a.y = 2 >>> a['y'] 2
Values can also be initially set by specifying them as keyword arguments to the constructor:
>>> a = Struct(z=3) >>> a['z'] 3 >>> a.z 3
Like dict instances, Struct`s have a `copy method to get a shallow copy of the instance:
>>> b = a.copy() >>> b.z 3
-
iter()¶
-
-
class
ivy.utils.struct.Struct(initializer=None, **extra_args)[source]¶ Bases:
ivy.utils.struct.ImmutableStructMutable implementation of a Struct
utils Module¶
Created on Mar 5, 2014
author: jakeret
-
class
ivy.utils.utils.Enum[source]¶ Bases:
frozensetA generic enumeration class. Inspired by: http://stackoverflow.com/questions/36932/whats-the-best-way-to-implement-an-enum-in-python/2182437#2182437 with some more syntactic sugar added.
An Enum class must be instanciated with a list of strings, that make the enumeration “label”:
>>> Animal = Enum('CAT', 'DOG')
Each label is available as an instance attribute, evaluating to itself:
>>> Animal.DOG 'DOG' >>> Animal.CAT == 'CAT' True
As a consequence, you can test for presence of an enumeration label by string value:
>>> 'DOG' in Animal True
Finally, enumeration labels can also be iterated upon:
>>> for a in Animal: print a DOG CAT