/usr/share/pyshared/cogent/recalculation/setting.py is in python-cogent 1.5.3-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | #!/usr/bin/python
"""Instances of these classes are assigned to different parameter/scopes
by a parameter controller"""
__author__ = "Peter Maxwell"
__copyright__ = "Copyright 2007-2012, The Cogent Project"
__credits__ = ["Peter Maxwell", "Gavin Huttley"]
__license__ = "GPL"
__version__ = "1.5.3"
__maintainer__ = "Peter Maxwell"
__email__ = "pm67nz@gmail.com"
__status__ = "Production"
class Setting(object):
pass
class Var(Setting):
# placeholder for a single optimiser parameter
is_constant = False
def __init__(self, bounds = None):
if bounds is None:
bounds = (None, None, None)
else:
assert len(bounds) == 3, bounds
(self.lower, self.value, self.upper) = bounds
def getBounds(self):
return (self.lower, self.value, self.upper)
def getDefaultValue(self):
return self.value
def __str__(self):
return "Var" # short as in table
def __repr__(self):
constraints = []
for (template, bound) in [
("%s<", self.lower),
("(%s)", self.value),
("<%s", self.upper)]:
if bound is not None:
constraints.append(template % bound)
return "Var(%s)" % " ".join(constraints)
class ConstVal(Setting):
# not to be confused with defns.Const. This is like a Var,
# assigned to a parameter which may have other Var values
# for other scopes.
is_constant = True
# Val interface
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value) # short as in table
def __repr__(self):
return "ConstVal(%s)" % repr(self.value)
# indep useful sometimes!
#def __eq__(self, other):
# return type(self) is type(other) and other.value == self.value
def getDefaultValue(self):
return self.value
def getBounds(self):
return (None, self.value, None)
|