Fix more flake8 cruft; remove a bunch of logging.
This commit is contained in:
@ -311,7 +311,7 @@ def rule_scout(ctx, codelet):
|
|||||||
for node in objectList
|
for node in objectList
|
||||||
]
|
]
|
||||||
descriptor = random.weighted_choice(objectList, weights)
|
descriptor = random.weighted_choice(objectList, weights)
|
||||||
# choose the relation (change the letmost object to "successor" or "d"
|
# choose the relation (change the leftmost object to "successor" or "d"
|
||||||
objectList = []
|
objectList = []
|
||||||
if changed.replacement.relation:
|
if changed.replacement.relation:
|
||||||
objectList += [changed.replacement.relation]
|
objectList += [changed.replacement.relation]
|
||||||
@ -878,7 +878,7 @@ def bottom_up_correspondence_scout(ctx, codelet):
|
|||||||
objectFromInitial.relevantDescriptions(),
|
objectFromInitial.relevantDescriptions(),
|
||||||
objectFromTarget.relevantDescriptions())
|
objectFromTarget.relevantDescriptions())
|
||||||
assert conceptMappings and __slippability(ctx, conceptMappings)
|
assert conceptMappings and __slippability(ctx, conceptMappings)
|
||||||
#find out if any are distinguishing
|
# find out if any are distinguishing
|
||||||
distinguishingMappings = [m for m in conceptMappings if m.distinguishing()]
|
distinguishingMappings = [m for m in conceptMappings if m.distinguishing()]
|
||||||
assert distinguishingMappings
|
assert distinguishingMappings
|
||||||
# if both objects span the strings, check to see if the
|
# if both objects span the strings, check to see if the
|
||||||
@ -936,7 +936,7 @@ def important_object_correspondence_scout(ctx, codelet):
|
|||||||
objectFromInitial.relevantDescriptions(),
|
objectFromInitial.relevantDescriptions(),
|
||||||
objectFromTarget.relevantDescriptions())
|
objectFromTarget.relevantDescriptions())
|
||||||
assert conceptMappings and __slippability(ctx, conceptMappings)
|
assert conceptMappings and __slippability(ctx, conceptMappings)
|
||||||
#find out if any are distinguishing
|
# find out if any are distinguishing
|
||||||
distinguishingMappings = [m for m in conceptMappings if m.distinguishing()]
|
distinguishingMappings = [m for m in conceptMappings if m.distinguishing()]
|
||||||
assert distinguishingMappings
|
assert distinguishingMappings
|
||||||
# if both objects span the strings, check to see if the
|
# if both objects span the strings, check to see if the
|
||||||
|
|||||||
@ -133,10 +133,8 @@ class Coderack(object):
|
|||||||
random = self.ctx.random
|
random = self.ctx.random
|
||||||
slipnet = self.ctx.slipnet
|
slipnet = self.ctx.slipnet
|
||||||
for node in slipnet.slipnodes:
|
for node in slipnet.slipnodes:
|
||||||
#logging.info('Trying slipnode: %s' % node.get_name())
|
|
||||||
if node.activation != 100.0:
|
if node.activation != 100.0:
|
||||||
continue
|
continue
|
||||||
#logging.info('using slipnode: %s' % node.get_name())
|
|
||||||
for codeletName in node.codelets:
|
for codeletName in node.codelets:
|
||||||
probability = self.probabilityOfPosting(codeletName)
|
probability = self.probabilityOfPosting(codeletName)
|
||||||
howMany = self.howManyToPost(codeletName)
|
howMany = self.howManyToPost(codeletName)
|
||||||
@ -181,7 +179,6 @@ class Coderack(object):
|
|||||||
self.codelets.remove(codelet)
|
self.codelets.remove(codelet)
|
||||||
|
|
||||||
def newCodelet(self, name, strength, arguments):
|
def newCodelet(self, name, strength, arguments):
|
||||||
#logging.debug('Posting new codelet called %s' % name)
|
|
||||||
urgency = getUrgencyBin(strength)
|
urgency = getUrgencyBin(strength)
|
||||||
newCodelet = Codelet(name, urgency, arguments, self.codeletsRun)
|
newCodelet = Codelet(name, urgency, arguments, self.codeletsRun)
|
||||||
self.post(newCodelet)
|
self.post(newCodelet)
|
||||||
|
|||||||
@ -1,13 +1,7 @@
|
|||||||
import logging
|
|
||||||
|
|
||||||
|
|
||||||
class ConceptMapping(object):
|
class ConceptMapping(object):
|
||||||
def __init__(self, initialDescriptionType, targetDescriptionType,
|
def __init__(self, initialDescriptionType, targetDescriptionType,
|
||||||
initialDescriptor, targetDescriptor,
|
initialDescriptor, targetDescriptor,
|
||||||
initialObject, targetObject):
|
initialObject, targetObject):
|
||||||
# pylint: disable=too-many-arguments
|
|
||||||
logging.info('make a map: %s-%s', initialDescriptionType.get_name(),
|
|
||||||
targetDescriptionType.get_name())
|
|
||||||
self.slipnet = initialDescriptionType.slipnet
|
self.slipnet = initialDescriptionType.slipnet
|
||||||
self.initialDescriptionType = initialDescriptionType
|
self.initialDescriptionType = initialDescriptionType
|
||||||
self.targetDescriptionType = targetDescriptionType
|
self.targetDescriptionType = targetDescriptionType
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import logging
|
|
||||||
from workspaceStructure import WorkspaceStructure
|
from workspaceStructure import WorkspaceStructure
|
||||||
|
|
||||||
|
|
||||||
@ -49,7 +48,6 @@ class Description(WorkspaceStructure):
|
|||||||
self.descriptionType.buffer = 100.0
|
self.descriptionType.buffer = 100.0
|
||||||
self.descriptor.buffer = 100.0
|
self.descriptor.buffer = 100.0
|
||||||
if not self.object.described(self.descriptor):
|
if not self.object.described(self.descriptor):
|
||||||
logging.info('Add %s to descriptions', self)
|
|
||||||
self.object.descriptions += [self]
|
self.object.descriptions += [self]
|
||||||
|
|
||||||
def breakDescription(self):
|
def breakDescription(self):
|
||||||
|
|||||||
@ -21,11 +21,10 @@ def __relevantDirection(objekt, slipnode):
|
|||||||
|
|
||||||
|
|
||||||
def __localRelevance(string, slipnode, relevance):
|
def __localRelevance(string, slipnode, relevance):
|
||||||
numberOfObjectsNotSpanning = numberOfMatches = 0.0
|
numberOfObjectsNotSpanning = 0.0
|
||||||
#logging.info("find relevance for a string: %s" % string);
|
numberOfMatches = 0.0
|
||||||
for objekt in string.objects:
|
for objekt in string.objects:
|
||||||
if not objekt.spansString():
|
if not objekt.spansString():
|
||||||
#logging.info('non spanner: %s' % objekt)
|
|
||||||
numberOfObjectsNotSpanning += 1.0
|
numberOfObjectsNotSpanning += 1.0
|
||||||
if relevance(objekt, slipnode):
|
if relevance(objekt, slipnode):
|
||||||
numberOfMatches += 1.0
|
numberOfMatches += 1.0
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
import logging
|
|
||||||
|
|
||||||
from description import Description
|
from description import Description
|
||||||
from workspaceObject import WorkspaceObject
|
from workspaceObject import WorkspaceObject
|
||||||
import formulas
|
import formulas
|
||||||
@ -29,16 +27,6 @@ class Group(WorkspaceObject):
|
|||||||
|
|
||||||
self.descriptions = []
|
self.descriptions = []
|
||||||
self.bondDescriptions = []
|
self.bondDescriptions = []
|
||||||
self.extrinsicDescriptions = []
|
|
||||||
self.outgoingBonds = []
|
|
||||||
self.incomingBonds = []
|
|
||||||
self.bonds = []
|
|
||||||
self.leftBond = None
|
|
||||||
self.rightBond = None
|
|
||||||
self.correspondence = None
|
|
||||||
self.changed = False
|
|
||||||
self.newAnswerLetter = False
|
|
||||||
self.clampSalience = False
|
|
||||||
self.name = ''
|
self.name = ''
|
||||||
|
|
||||||
if self.bondList and len(self.bondList):
|
if self.bondList and len(self.bondList):
|
||||||
@ -55,31 +43,26 @@ class Group(WorkspaceObject):
|
|||||||
letter = self.objectList[0].getDescriptor(self.facet)
|
letter = self.objectList[0].getDescriptor(self.facet)
|
||||||
self.addDescription(self.facet, letter)
|
self.addDescription(self.facet, letter)
|
||||||
if self.directionCategory:
|
if self.directionCategory:
|
||||||
self.addDescription(slipnet.directionCategory,
|
self.addDescription(slipnet.directionCategory, self.directionCategory)
|
||||||
self.directionCategory)
|
|
||||||
if self.spansString():
|
if self.spansString():
|
||||||
self.addDescription(slipnet.stringPositionCategory, slipnet.whole)
|
self.addDescription(slipnet.stringPositionCategory, slipnet.whole)
|
||||||
elif self.leftIndex == 1:
|
elif self.leftmost:
|
||||||
self.addDescription(
|
self.addDescription(slipnet.stringPositionCategory, slipnet.leftmost)
|
||||||
slipnet.stringPositionCategory, slipnet.leftmost)
|
elif self.rightmost:
|
||||||
elif self.rightIndex == self.string.length:
|
self.addDescription(slipnet.stringPositionCategory, slipnet.rightmost)
|
||||||
self.addDescription(
|
|
||||||
slipnet.stringPositionCategory, slipnet.rightmost)
|
|
||||||
elif self.middleObject():
|
elif self.middleObject():
|
||||||
self.addDescription(
|
self.addDescription(slipnet.stringPositionCategory, slipnet.middle)
|
||||||
slipnet.stringPositionCategory, slipnet.middle)
|
|
||||||
self.add_length_description_category()
|
self.add_length_description_category()
|
||||||
|
|
||||||
def add_length_description_category(self):
|
def add_length_description_category(self):
|
||||||
#check whether or not to add length description category
|
# check whether or not to add length description category
|
||||||
random = self.ctx.random
|
random = self.ctx.random
|
||||||
slipnet = self.ctx.slipnet
|
slipnet = self.ctx.slipnet
|
||||||
probability = self.lengthDescriptionProbability()
|
probability = self.lengthDescriptionProbability()
|
||||||
if random.coinFlip(probability):
|
if random.coinFlip(probability):
|
||||||
length = len(self.objectList)
|
length = len(self.objectList)
|
||||||
if length < 6:
|
if length < 6:
|
||||||
self.addDescription(slipnet.length,
|
self.addDescription(slipnet.length, slipnet.numbers[length - 1])
|
||||||
slipnet.numbers[length - 1])
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
s = self.string.__str__()
|
s = self.string.__str__()
|
||||||
@ -136,7 +119,6 @@ class Group(WorkspaceObject):
|
|||||||
|
|
||||||
def activateDescriptions(self):
|
def activateDescriptions(self):
|
||||||
for description in self.descriptions:
|
for description in self.descriptions:
|
||||||
logging.info('Activate: %s', description)
|
|
||||||
description.descriptor.buffer = 100.0
|
description.descriptor.buffer = 100.0
|
||||||
|
|
||||||
def lengthDescriptionProbability(self):
|
def lengthDescriptionProbability(self):
|
||||||
@ -150,7 +132,7 @@ class Group(WorkspaceObject):
|
|||||||
probability = 0.5 ** fred
|
probability = 0.5 ** fred
|
||||||
value = temperature.getAdjustedProbability(probability)
|
value = temperature.getAdjustedProbability(probability)
|
||||||
if value < 0.06:
|
if value < 0.06:
|
||||||
value = 0.0 # otherwise 1/20 chance always
|
value = 0.0
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def break_the_structure(self):
|
def break_the_structure(self):
|
||||||
@ -214,12 +196,10 @@ class Group(WorkspaceObject):
|
|||||||
def numberOfLocalSupportingGroups(self):
|
def numberOfLocalSupportingGroups(self):
|
||||||
count = 0
|
count = 0
|
||||||
for objekt in self.string.objects:
|
for objekt in self.string.objects:
|
||||||
if isinstance(objekt, Group):
|
if isinstance(objekt, Group) and self.isOutsideOf(objekt):
|
||||||
if (objekt.rightIndex < self.leftIndex or
|
if (objekt.groupCategory == self.groupCategory and
|
||||||
objekt.leftIndex > self.rightIndex):
|
objekt.directionCategory == self.directionCategory):
|
||||||
if (objekt.groupCategory == self.groupCategory and
|
count += 1
|
||||||
objekt.directionCategory == self.directionCategory):
|
|
||||||
count += 1
|
|
||||||
return count
|
return count
|
||||||
|
|
||||||
def localDensity(self):
|
def localDensity(self):
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
import logging
|
|
||||||
|
|
||||||
from slipnode import Slipnode
|
from slipnode import Slipnode
|
||||||
from sliplink import Sliplink
|
from sliplink import Sliplink
|
||||||
|
|
||||||
@ -12,7 +10,6 @@ class Slipnet(object):
|
|||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
logging.debug('slipnet.reset()')
|
|
||||||
self.numberOfUpdates = 0
|
self.numberOfUpdates = 0
|
||||||
for node in self.slipnodes:
|
for node in self.slipnodes:
|
||||||
node.reset()
|
node.reset()
|
||||||
@ -20,7 +17,6 @@ class Slipnet(object):
|
|||||||
node.clampHigh()
|
node.clampHigh()
|
||||||
|
|
||||||
def update(self, random):
|
def update(self, random):
|
||||||
logging.debug('slipnet.update()')
|
|
||||||
self.numberOfUpdates += 1
|
self.numberOfUpdates += 1
|
||||||
if self.numberOfUpdates == 50:
|
if self.numberOfUpdates == 50:
|
||||||
for node in self.initiallyClampedSlipnodes:
|
for node in self.initiallyClampedSlipnodes:
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
import logging
|
|
||||||
|
|
||||||
import formulas
|
import formulas
|
||||||
from bond import Bond
|
from bond import Bond
|
||||||
from correspondence import Correspondence
|
from correspondence import Correspondence
|
||||||
@ -59,21 +57,24 @@ class Workspace(object):
|
|||||||
self.calculateTotalUnhappiness()
|
self.calculateTotalUnhappiness()
|
||||||
|
|
||||||
def calculateIntraStringUnhappiness(self):
|
def calculateIntraStringUnhappiness(self):
|
||||||
value = sum(o.relativeImportance * o.intraStringUnhappiness
|
value = sum(
|
||||||
for o in self.objects) / 2.0
|
o.relativeImportance * o.intraStringUnhappiness
|
||||||
|
for o in self.objects
|
||||||
|
) / 2.0
|
||||||
self.intraStringUnhappiness = min(value, 100.0)
|
self.intraStringUnhappiness = min(value, 100.0)
|
||||||
|
|
||||||
def calculateInterStringUnhappiness(self):
|
def calculateInterStringUnhappiness(self):
|
||||||
value = sum(o.relativeImportance * o.interStringUnhappiness
|
value = sum(
|
||||||
for o in self.objects) / 2.0
|
o.relativeImportance * o.interStringUnhappiness
|
||||||
|
for o in self.objects
|
||||||
|
) / 2.0
|
||||||
self.interStringUnhappiness = min(value, 100.0)
|
self.interStringUnhappiness = min(value, 100.0)
|
||||||
|
|
||||||
def calculateTotalUnhappiness(self):
|
def calculateTotalUnhappiness(self):
|
||||||
for o in self.objects:
|
value = sum(
|
||||||
logging.info("%s, totalUnhappiness: %d, relativeImportance: %d",
|
o.relativeImportance * o.totalUnhappiness
|
||||||
o, o.totalUnhappiness, o.relativeImportance * 1000)
|
for o in self.objects
|
||||||
value = sum(o.relativeImportance * o.totalUnhappiness
|
) / 2.0
|
||||||
for o in self.objects) / 2.0
|
|
||||||
self.totalUnhappiness = min(value, 100.0)
|
self.totalUnhappiness = min(value, 100.0)
|
||||||
|
|
||||||
def updateEverything(self):
|
def updateEverything(self):
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
import logging
|
|
||||||
|
|
||||||
|
|
||||||
def __chooseObjectFromList(ctx, objects, attribute):
|
def __chooseObjectFromList(ctx, objects, attribute):
|
||||||
random = ctx.random
|
random = ctx.random
|
||||||
@ -16,8 +14,6 @@ def __chooseObjectFromList(ctx, objects, attribute):
|
|||||||
def chooseUnmodifiedObject(ctx, attribute, inObjects):
|
def chooseUnmodifiedObject(ctx, attribute, inObjects):
|
||||||
workspace = ctx.workspace
|
workspace = ctx.workspace
|
||||||
objects = [o for o in inObjects if o.string != workspace.modified]
|
objects = [o for o in inObjects if o.string != workspace.modified]
|
||||||
if not objects:
|
|
||||||
logging.warning('no objects available in initial or target strings')
|
|
||||||
return __chooseObjectFromList(ctx, objects, attribute)
|
return __chooseObjectFromList(ctx, objects, attribute)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
import logging
|
|
||||||
|
|
||||||
from description import Description
|
from description import Description
|
||||||
from formulas import weightedAverage
|
from formulas import weightedAverage
|
||||||
from workspaceStructure import WorkspaceStructure
|
from workspaceStructure import WorkspaceStructure
|
||||||
@ -11,19 +9,14 @@ class WorkspaceObject(WorkspaceStructure):
|
|||||||
WorkspaceStructure.__init__(self, workspaceString.ctx)
|
WorkspaceStructure.__init__(self, workspaceString.ctx)
|
||||||
self.string = workspaceString
|
self.string = workspaceString
|
||||||
self.descriptions = []
|
self.descriptions = []
|
||||||
self.extrinsicDescriptions = []
|
|
||||||
self.incomingBonds = []
|
|
||||||
self.outgoingBonds = []
|
|
||||||
self.bonds = []
|
self.bonds = []
|
||||||
self.group = None
|
self.group = None
|
||||||
self.changed = None
|
self.changed = False
|
||||||
self.correspondence = None
|
self.correspondence = None
|
||||||
self.clampSalience = False
|
|
||||||
self.rawImportance = 0.0
|
self.rawImportance = 0.0
|
||||||
self.relativeImportance = 0.0
|
self.relativeImportance = 0.0
|
||||||
self.leftBond = None
|
self.leftBond = None
|
||||||
self.rightBond = None
|
self.rightBond = None
|
||||||
self.newAnswerLetter = False
|
|
||||||
self.name = ''
|
self.name = ''
|
||||||
self.replacement = None
|
self.replacement = None
|
||||||
self.rightIndex = 0
|
self.rightIndex = 0
|
||||||
@ -45,19 +38,15 @@ class WorkspaceObject(WorkspaceStructure):
|
|||||||
|
|
||||||
def addDescription(self, descriptionType, descriptor):
|
def addDescription(self, descriptionType, descriptor):
|
||||||
description = Description(self, descriptionType, descriptor)
|
description = Description(self, descriptionType, descriptor)
|
||||||
logging.info("Adding description: %s to %s", description, self)
|
|
||||||
self.descriptions += [description]
|
self.descriptions += [description]
|
||||||
|
|
||||||
def addDescriptions(self, descriptions):
|
def addDescriptions(self, descriptions):
|
||||||
workspace = self.ctx.workspace
|
workspace = self.ctx.workspace
|
||||||
copy = descriptions[:] # in case we add to our own descriptions
|
copy = descriptions[:] # in case we add to our own descriptions
|
||||||
for description in copy:
|
for description in copy:
|
||||||
logging.info('might add: %s', description)
|
|
||||||
if not self.containsDescription(description):
|
if not self.containsDescription(description):
|
||||||
self.addDescription(description.descriptionType,
|
self.addDescription(description.descriptionType,
|
||||||
description.descriptor)
|
description.descriptor)
|
||||||
else:
|
|
||||||
logging.info("Won't add it")
|
|
||||||
workspace.buildDescriptions(self)
|
workspace.buildDescriptions(self)
|
||||||
|
|
||||||
def __calculateIntraStringHappiness(self):
|
def __calculateIntraStringHappiness(self):
|
||||||
@ -97,26 +86,24 @@ class WorkspaceObject(WorkspaceStructure):
|
|||||||
averageHappiness = (intraStringHappiness + interStringHappiness) / 2
|
averageHappiness = (intraStringHappiness + interStringHappiness) / 2
|
||||||
self.totalUnhappiness = 100.0 - averageHappiness
|
self.totalUnhappiness = 100.0 - averageHappiness
|
||||||
|
|
||||||
if self.clampSalience:
|
self.intraStringSalience = weightedAverage((
|
||||||
self.intraStringSalience = 100.0
|
(self.relativeImportance, 0.2),
|
||||||
self.interStringSalience = 100.0
|
(self.intraStringUnhappiness, 0.8)
|
||||||
else:
|
))
|
||||||
self.intraStringSalience = weightedAverage((
|
self.interStringSalience = weightedAverage((
|
||||||
(self.relativeImportance, 0.2),
|
(self.relativeImportance, 0.8),
|
||||||
(self.intraStringUnhappiness, 0.8)))
|
(self.interStringUnhappiness, 0.2)
|
||||||
self.interStringSalience = weightedAverage((
|
))
|
||||||
(self.relativeImportance, 0.8),
|
self.totalSalience = (self.intraStringSalience + self.interStringSalience) / 2.0
|
||||||
(self.interStringUnhappiness, 0.2)))
|
|
||||||
self.totalSalience = (self.intraStringSalience +
|
|
||||||
self.interStringSalience) / 2.0
|
|
||||||
logging.info('Set salience of %s to %f = (%f + %f)/2',
|
|
||||||
self.__str__(), self.totalSalience,
|
|
||||||
self.intraStringSalience, self.interStringSalience)
|
|
||||||
|
|
||||||
def isWithin(self, other):
|
def isWithin(self, other):
|
||||||
return (self.leftIndex >= other.leftIndex and
|
return (self.leftIndex >= other.leftIndex and
|
||||||
self.rightIndex <= other.rightIndex)
|
self.rightIndex <= other.rightIndex)
|
||||||
|
|
||||||
|
def isOutsideOf(self, other):
|
||||||
|
return (self.leftIndex > other.rightIndex or
|
||||||
|
self.rightIndex < other.leftIndex)
|
||||||
|
|
||||||
def relevantDescriptions(self):
|
def relevantDescriptions(self):
|
||||||
return [d for d in self.descriptions
|
return [d for d in self.descriptions
|
||||||
if d.descriptionType.fully_active()]
|
if d.descriptionType.fully_active()]
|
||||||
@ -124,7 +111,6 @@ class WorkspaceObject(WorkspaceStructure):
|
|||||||
def getPossibleDescriptions(self, descriptionType):
|
def getPossibleDescriptions(self, descriptionType):
|
||||||
from group import Group # gross, TODO FIXME
|
from group import Group # gross, TODO FIXME
|
||||||
slipnet = self.ctx.slipnet
|
slipnet = self.ctx.slipnet
|
||||||
logging.info('getting possible descriptions for %s', self)
|
|
||||||
descriptions = []
|
descriptions = []
|
||||||
for link in descriptionType.instanceLinks:
|
for link in descriptionType.instanceLinks:
|
||||||
node = link.destination
|
node = link.destination
|
||||||
@ -138,10 +124,6 @@ class WorkspaceObject(WorkspaceStructure):
|
|||||||
descriptions += [node]
|
descriptions += [node]
|
||||||
if node == slipnet.middle and self.middleObject():
|
if node == slipnet.middle and self.middleObject():
|
||||||
descriptions += [node]
|
descriptions += [node]
|
||||||
s = ''
|
|
||||||
for d in descriptions:
|
|
||||||
s = '%s, %s' % (s, d.get_name())
|
|
||||||
logging.info(s)
|
|
||||||
return descriptions
|
return descriptions
|
||||||
|
|
||||||
def containsDescription(self, sought):
|
def containsDescription(self, sought):
|
||||||
@ -179,10 +161,7 @@ class WorkspaceObject(WorkspaceStructure):
|
|||||||
|
|
||||||
def getDescriptor(self, descriptionType):
|
def getDescriptor(self, descriptionType):
|
||||||
"""The description attached to this object of the description type."""
|
"""The description attached to this object of the description type."""
|
||||||
logging.info("\nIn %s, trying for type: %s",
|
|
||||||
self, descriptionType.get_name())
|
|
||||||
for description in self.descriptions:
|
for description in self.descriptions:
|
||||||
logging.info("Trying description: %s", description)
|
|
||||||
if description.descriptionType == descriptionType:
|
if description.descriptionType == descriptionType:
|
||||||
return description.descriptor
|
return description.descriptor
|
||||||
return None
|
return None
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import logging
|
|
||||||
from group import Group
|
from group import Group
|
||||||
from letter import Letter
|
from letter import Letter
|
||||||
|
|
||||||
@ -32,19 +31,6 @@ class WorkspaceString(object):
|
|||||||
return '%s with %d letters, %d objects, %d bonds' % (
|
return '%s with %d letters, %d objects, %d bonds' % (
|
||||||
self.string, len(self.letters), len(self.objects), len(self.bonds))
|
self.string, len(self.letters), len(self.objects), len(self.bonds))
|
||||||
|
|
||||||
def log(self, heading):
|
|
||||||
s = '%s: %s - ' % (heading, self)
|
|
||||||
for l in self.letters:
|
|
||||||
s += ' %s' % l
|
|
||||||
s += '; '
|
|
||||||
for o in self.objects:
|
|
||||||
s += ' %s' % o
|
|
||||||
s += '; '
|
|
||||||
for b in self.bonds:
|
|
||||||
s += ' %s' % b
|
|
||||||
s += '.'
|
|
||||||
logging.info(s)
|
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return len(self.string)
|
return len(self.string)
|
||||||
|
|
||||||
@ -59,9 +45,6 @@ class WorkspaceString(object):
|
|||||||
o.relativeImportance = 0.0
|
o.relativeImportance = 0.0
|
||||||
else:
|
else:
|
||||||
for o in self.objects:
|
for o in self.objects:
|
||||||
logging.info('object: %s, relative: %d = raw: %d / total: %d',
|
|
||||||
o, o.relativeImportance * 1000, o.rawImportance,
|
|
||||||
total)
|
|
||||||
o.relativeImportance = o.rawImportance / total
|
o.relativeImportance = o.rawImportance / total
|
||||||
|
|
||||||
def updateIntraStringUnhappiness(self):
|
def updateIntraStringUnhappiness(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user