Minor Pythonicity cleanups.
No functional change.
This commit is contained in:
@ -79,6 +79,7 @@ class ConceptMapping(object):
|
|||||||
def sameDescriptors(self, other):
|
def sameDescriptors(self, other):
|
||||||
if self.sameInitialDescriptor(other):
|
if self.sameInitialDescriptor(other):
|
||||||
return self.sameTargetDescriptor(other)
|
return self.sameTargetDescriptor(other)
|
||||||
|
return False
|
||||||
|
|
||||||
def sameKind(self, other):
|
def sameKind(self, other):
|
||||||
return self.sameTypes(other) and self.sameDescriptors(other)
|
return self.sameTypes(other) and self.sameDescriptors(other)
|
||||||
@ -87,10 +88,10 @@ class ConceptMapping(object):
|
|||||||
return self.sameTypes(other) and self.sameInitialDescriptor(other)
|
return self.sameTypes(other) and self.sameInitialDescriptor(other)
|
||||||
|
|
||||||
def isContainedBy(self, mappings):
|
def isContainedBy(self, mappings):
|
||||||
return any([self.sameKind(mapping) for mapping in mappings])
|
return any(self.sameKind(mapping) for mapping in mappings)
|
||||||
|
|
||||||
def isNearlyContainedBy(self, mappings):
|
def isNearlyContainedBy(self, mappings):
|
||||||
return any([self.nearlySameKind(mapping) for mapping in mappings])
|
return any(self.nearlySameKind(mapping) for mapping in mappings)
|
||||||
|
|
||||||
def related(self, other):
|
def related(self, other):
|
||||||
if self.initialDescriptor.related(other.initialDescriptor):
|
if self.initialDescriptor.related(other.initialDescriptor):
|
||||||
@ -136,10 +137,12 @@ class ConceptMapping(object):
|
|||||||
def relevant(self):
|
def relevant(self):
|
||||||
if self.initialDescriptionType.fully_active():
|
if self.initialDescriptionType.fully_active():
|
||||||
return self.targetDescriptionType.fully_active()
|
return self.targetDescriptionType.fully_active()
|
||||||
|
return False
|
||||||
|
|
||||||
def slippage(self):
|
def slippage(self):
|
||||||
if self.label != slipnet.sameness:
|
if self.label != slipnet.sameness:
|
||||||
return self.label != slipnet.identity
|
return self.label != slipnet.identity
|
||||||
|
return False
|
||||||
|
|
||||||
def symmetricVersion(self):
|
def symmetricVersion(self):
|
||||||
if not self.slippage():
|
if not self.slippage():
|
||||||
|
|||||||
@ -91,8 +91,8 @@ class Rule(WorkspaceStructure):
|
|||||||
if correspondence.objectFromInitial != changed:
|
if correspondence.objectFromInitial != changed:
|
||||||
return False
|
return False
|
||||||
# it is incompatible if the rule descriptor is not in the mapping list
|
# it is incompatible if the rule descriptor is not in the mapping list
|
||||||
return bool([m for m in correspondence.conceptMappings
|
return any(m.initialDescriptor == self.descriptor
|
||||||
if m.initialDescriptor == self.descriptor])
|
for m in correspondence.conceptMappings)
|
||||||
|
|
||||||
def __changeString(self, string):
|
def __changeString(self, string):
|
||||||
# applies the changes to self string ie. successor
|
# applies the changes to self string ie. successor
|
||||||
|
|||||||
@ -35,7 +35,8 @@ class SlipNet(object):
|
|||||||
|
|
||||||
def setConceptualDepths(self, depth):
|
def setConceptualDepths(self, depth):
|
||||||
logging.debug('slipnet set all depths to %f', depth)
|
logging.debug('slipnet set all depths to %f', depth)
|
||||||
_ = [node.setConceptualDepth(depth) for node in self.slipnodes]
|
for node in self.slipnodes:
|
||||||
|
node.setConceptualDepth(depth)
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
logging.debug('slipnet.reset()')
|
logging.debug('slipnet.reset()')
|
||||||
@ -49,8 +50,10 @@ class SlipNet(object):
|
|||||||
logging.debug('slipnet.update()')
|
logging.debug('slipnet.update()')
|
||||||
self.numberOfUpdates += 1
|
self.numberOfUpdates += 1
|
||||||
if self.numberOfUpdates == 50:
|
if self.numberOfUpdates == 50:
|
||||||
_ = [node.unclamp() for node in self.initiallyClampedSlipnodes]
|
for node in self.initiallyClampedSlipnodes:
|
||||||
_ = [node.update() for node in self.slipnodes]
|
node.unclamp()
|
||||||
|
for node in self.slipnodes:
|
||||||
|
node.update()
|
||||||
for node in self.slipnodes:
|
for node in self.slipnodes:
|
||||||
node.spread_activation()
|
node.spread_activation()
|
||||||
for node in self.slipnodes:
|
for node in self.slipnodes:
|
||||||
|
|||||||
@ -13,7 +13,7 @@ def jump_threshold():
|
|||||||
|
|
||||||
def points_at(links, other):
|
def points_at(links, other):
|
||||||
"""Whether any of the links points at the other"""
|
"""Whether any of the links points at the other"""
|
||||||
return any([l.points_at(other) for l in links])
|
return any(l.points_at(other) for l in links)
|
||||||
|
|
||||||
|
|
||||||
class Slipnode(object):
|
class Slipnode(object):
|
||||||
@ -124,8 +124,7 @@ class Slipnode(object):
|
|||||||
for l in self.outgoingLinks if l.label == relation]
|
for l in self.outgoingLinks if l.label == relation]
|
||||||
if destinations:
|
if destinations:
|
||||||
return destinations[0]
|
return destinations[0]
|
||||||
node = None
|
return None
|
||||||
return node
|
|
||||||
|
|
||||||
def getBondCategory(self, destination):
|
def getBondCategory(self, destination):
|
||||||
"""Return the label of the link between these nodes if it exists.
|
"""Return the label of the link between these nodes if it exists.
|
||||||
@ -150,13 +149,13 @@ class Slipnode(object):
|
|||||||
|
|
||||||
def spread_activation(self):
|
def spread_activation(self):
|
||||||
if self.fully_active():
|
if self.fully_active():
|
||||||
_ = [link.spread_activation() for link in self.outgoingLinks]
|
for link in self.outgoingLinks:
|
||||||
|
link.spread_activation()
|
||||||
|
|
||||||
def addBuffer(self):
|
def addBuffer(self):
|
||||||
if self.unclamped():
|
if self.unclamped():
|
||||||
self.activation += self.buffer
|
self.activation += self.buffer
|
||||||
self.activation = min(self.activation, 100)
|
self.activation = min(max(0, self.activation), 100)
|
||||||
self.activation = max(self.activation, 0)
|
|
||||||
|
|
||||||
def can_jump(self):
|
def can_jump(self):
|
||||||
if self.activation <= jump_threshold():
|
if self.activation <= jump_threshold():
|
||||||
|
|||||||
@ -161,7 +161,7 @@ class WorkspaceObject(WorkspaceStructure):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def described(self, slipnode):
|
def described(self, slipnode):
|
||||||
return bool([d for d in self.descriptions if d.descriptor == slipnode])
|
return any(d.descriptor == slipnode for d in self.descriptions)
|
||||||
|
|
||||||
def middleObject(self):
|
def middleObject(self):
|
||||||
# only works if string is 3 chars long
|
# only works if string is 3 chars long
|
||||||
|
|||||||
Reference in New Issue
Block a user