Fix a bunch of flake8 spam. NFC.
This commit is contained in:
@ -1 +1 @@
|
|||||||
from copycat import Copycat
|
from copycat import Copycat # noqa
|
||||||
|
|||||||
@ -30,17 +30,20 @@ class Bond(WorkspaceStructure):
|
|||||||
|
|
||||||
def flippedVersion(self):
|
def flippedVersion(self):
|
||||||
slipnet = self.ctx.slipnet
|
slipnet = self.ctx.slipnet
|
||||||
return Bond(self.ctx,
|
return Bond(
|
||||||
|
self.ctx,
|
||||||
self.destination, self.source,
|
self.destination, self.source,
|
||||||
self.category.getRelatedNode(slipnet.opposite),
|
self.category.getRelatedNode(slipnet.opposite),
|
||||||
self.facet, self.destinationDescriptor, self.sourceDescriptor)
|
self.facet, self.destinationDescriptor, self.sourceDescriptor
|
||||||
|
)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<Bond: %s>' % self.__str__()
|
return '<Bond: %s>' % self.__str__()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return '%s bond between %s and %s' % (
|
return '%s bond between %s and %s' % (
|
||||||
self.category.name, self.leftObject, self.rightObject)
|
self.category.name, self.leftObject, self.rightObject,
|
||||||
|
)
|
||||||
|
|
||||||
def buildBond(self):
|
def buildBond(self):
|
||||||
workspace = self.ctx.workspace
|
workspace = self.ctx.workspace
|
||||||
@ -82,9 +85,10 @@ class Bond(WorkspaceStructure):
|
|||||||
else:
|
else:
|
||||||
objekt = self.leftObject.correspondence.objectFromInitial
|
objekt = self.leftObject.correspondence.objectFromInitial
|
||||||
if objekt.leftmost and objekt.rightBond:
|
if objekt.leftmost and objekt.rightBond:
|
||||||
if (objekt.rightBond.directionCategory and
|
if (
|
||||||
objekt.rightBond.directionCategory !=
|
objekt.rightBond.directionCategory and
|
||||||
self.directionCategory):
|
objekt.rightBond.directionCategory != self.directionCategory
|
||||||
|
):
|
||||||
incompatibles += [correspondence]
|
incompatibles += [correspondence]
|
||||||
if self.rightObject.rightmost and self.rightObject.correspondence:
|
if self.rightObject.rightmost and self.rightObject.correspondence:
|
||||||
correspondence = self.rightObject.correspondence
|
correspondence = self.rightObject.correspondence
|
||||||
@ -93,9 +97,10 @@ class Bond(WorkspaceStructure):
|
|||||||
else:
|
else:
|
||||||
objekt = self.rightObject.correspondence.objectFromInitial
|
objekt = self.rightObject.correspondence.objectFromInitial
|
||||||
if objekt.rightmost and objekt.leftBond:
|
if objekt.rightmost and objekt.leftBond:
|
||||||
if (objekt.leftBond.directionCategory and
|
if (
|
||||||
objekt.leftBond.directionCategory !=
|
objekt.leftBond.directionCategory and
|
||||||
self.directionCategory):
|
objekt.leftBond.directionCategory != self.directionCategory
|
||||||
|
):
|
||||||
incompatibles += [correspondence]
|
incompatibles += [correspondence]
|
||||||
return incompatibles
|
return incompatibles
|
||||||
|
|
||||||
@ -160,9 +165,11 @@ class Bond(WorkspaceStructure):
|
|||||||
if object1.beside(object2):
|
if object1.beside(object2):
|
||||||
slotSum += 1.0
|
slotSum += 1.0
|
||||||
for bond in self.string.bonds:
|
for bond in self.string.bonds:
|
||||||
if (bond != self and
|
if (
|
||||||
self.sameCategories(bond) and
|
bond != self and
|
||||||
self.myEnds(object1, object2)):
|
self.sameCategories(bond) and
|
||||||
|
self.myEnds(object1, object2)
|
||||||
|
):
|
||||||
supportSum += 1.0
|
supportSum += 1.0
|
||||||
try:
|
try:
|
||||||
return 100.0 * supportSum / slotSum
|
return 100.0 * supportSum / slotSum
|
||||||
@ -185,20 +192,23 @@ def possibleGroupBonds(bondCategory, directionCategory, bondFacet, bonds):
|
|||||||
result = []
|
result = []
|
||||||
for bond in bonds:
|
for bond in bonds:
|
||||||
slipnet = bond.ctx.slipnet
|
slipnet = bond.ctx.slipnet
|
||||||
if (bond.category == bondCategory and
|
if (
|
||||||
bond.directionCategory == directionCategory):
|
bond.category == bondCategory and
|
||||||
|
bond.directionCategory == directionCategory
|
||||||
|
):
|
||||||
result += [bond]
|
result += [bond]
|
||||||
else:
|
else:
|
||||||
# a modified bond might be made
|
# a modified bond might be made
|
||||||
if bondCategory == slipnet.sameness:
|
if bond.category == bondCategory:
|
||||||
return None # a different bond cannot be made here
|
return None # a different bond cannot be made here
|
||||||
if (bond.category == bondCategory or
|
if bond.directionCategory == directionCategory:
|
||||||
bond.directionCategory == directionCategory):
|
|
||||||
return None # a different bond cannot be made here
|
return None # a different bond cannot be made here
|
||||||
if bond.category == slipnet.sameness:
|
if slipnet.sameness in [bondCategory, bond.category]:
|
||||||
return None
|
return None
|
||||||
bond = Bond(bond.ctx, bond.destination, bond.source, bondCategory,
|
bond = Bond(
|
||||||
bondFacet, bond.destinationDescriptor,
|
bond.ctx, bond.destination, bond.source, bondCategory,
|
||||||
bond.sourceDescriptor)
|
bondFacet, bond.destinationDescriptor,
|
||||||
|
bond.sourceDescriptor
|
||||||
|
)
|
||||||
result += [bond]
|
result += [bond]
|
||||||
return result
|
return result
|
||||||
|
|||||||
@ -356,17 +356,18 @@ def replacement_finder(ctx, codelet):
|
|||||||
position = letterOfInitialString.leftIndex
|
position = letterOfInitialString.leftIndex
|
||||||
moreLetters = [o for o in workspace.modified.objects
|
moreLetters = [o for o in workspace.modified.objects
|
||||||
if isinstance(o, Letter) and o.leftIndex == position]
|
if isinstance(o, Letter) and o.leftIndex == position]
|
||||||
letterOfModifiedString = moreLetters and moreLetters[0] or None
|
if not moreLetters:
|
||||||
assert letterOfModifiedString
|
return
|
||||||
position -= 1
|
letterOfModifiedString = moreLetters[0]
|
||||||
initialAscii = ord(workspace.initialString[position])
|
initialAscii = ord(workspace.initialString[position - 1])
|
||||||
modifiedAscii = ord(workspace.modifiedString[position])
|
modifiedAscii = ord(workspace.modifiedString[position - 1])
|
||||||
diff = initialAscii - modifiedAscii
|
diff = initialAscii - modifiedAscii
|
||||||
if abs(diff) < 2:
|
if abs(diff) < 2:
|
||||||
relations = {
|
relations = {
|
||||||
0: slipnet.sameness,
|
0: slipnet.sameness,
|
||||||
-1: slipnet.successor,
|
-1: slipnet.successor,
|
||||||
1: slipnet.predecessor}
|
1: slipnet.predecessor
|
||||||
|
}
|
||||||
relation = relations[diff]
|
relation = relations[diff]
|
||||||
logging.info('Relation found: %s', relation.name)
|
logging.info('Relation found: %s', relation.name)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -22,7 +22,7 @@ class ConceptMapping(object):
|
|||||||
self.__str__(), self.initialDescriptor, self.targetDescriptor)
|
self.__str__(), self.initialDescriptor, self.targetDescriptor)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.label and self.label.name or 'anonymous'
|
return self.label.name if self.label else 'anonymous'
|
||||||
|
|
||||||
def slippability(self):
|
def slippability(self):
|
||||||
association = self.__degreeOfAssociation()
|
association = self.__degreeOfAssociation()
|
||||||
@ -125,9 +125,8 @@ class ConceptMapping(object):
|
|||||||
# means that letter->group supports letter->group, even though these
|
# means that letter->group supports letter->group, even though these
|
||||||
# concept-mappings have no label.
|
# concept-mappings have no label.
|
||||||
|
|
||||||
if self.initialDescriptor == other.initialDescriptor:
|
if self.sameDescriptors(other):
|
||||||
if self.targetDescriptor == other.targetDescriptor:
|
return True
|
||||||
return True
|
|
||||||
# if the descriptors are not related return false
|
# if the descriptors are not related return false
|
||||||
if not self.related(other):
|
if not self.related(other):
|
||||||
return False
|
return False
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
import logging
|
|
||||||
|
|
||||||
from coderack import Coderack
|
from coderack import Coderack
|
||||||
from randomness import Randomness
|
from randomness import Randomness
|
||||||
from slipnet import Slipnet
|
from slipnet import Slipnet
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import curses
|
import curses
|
||||||
import logging
|
import logging
|
||||||
import sys
|
|
||||||
|
|
||||||
from copycat import Copycat
|
from copycat import Copycat
|
||||||
from curses_reporter import CursesReporter
|
from curses_reporter import CursesReporter
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
import sys
|
|
||||||
|
|
||||||
from copycat import Copycat, Reporter
|
from copycat import Copycat, Reporter
|
||||||
|
|
||||||
|
|||||||
@ -7,23 +7,10 @@ from sliplink import Sliplink
|
|||||||
class Slipnet(object):
|
class Slipnet(object):
|
||||||
# pylint: disable=too-many-instance-attributes
|
# pylint: disable=too-many-instance-attributes
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
logging.debug("Slipnet.__init__()")
|
|
||||||
self.slipnodes = []
|
|
||||||
self.sliplinks = []
|
|
||||||
self.bondFacets = []
|
|
||||||
self.numberOfUpdates = 0
|
|
||||||
self.__addInitialNodes()
|
self.__addInitialNodes()
|
||||||
self.__addInitialLinks()
|
self.__addInitialLinks()
|
||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
return '<slipnet>'
|
|
||||||
|
|
||||||
def setConceptualDepths(self, depth):
|
|
||||||
logging.debug('slipnet set all depths to %f', depth)
|
|
||||||
for node in self.slipnodes:
|
|
||||||
node.setConceptualDepth(depth)
|
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
logging.debug('slipnet.reset()')
|
logging.debug('slipnet.reset()')
|
||||||
self.numberOfUpdates = 0
|
self.numberOfUpdates = 0
|
||||||
@ -126,8 +113,10 @@ class Slipnet(object):
|
|||||||
self.bondFacet = self.__addNode('bondFacet', 90.0)
|
self.bondFacet = self.__addNode('bondFacet', 90.0)
|
||||||
|
|
||||||
# specify the descriptor types that bonds can form between
|
# specify the descriptor types that bonds can form between
|
||||||
self.bondFacets += [self.letterCategory]
|
self.bondFacets = [
|
||||||
self.bondFacets += [self.length]
|
self.letterCategory,
|
||||||
|
self.length,
|
||||||
|
]
|
||||||
|
|
||||||
# some factors are considered "very relevant" a priori
|
# some factors are considered "very relevant" a priori
|
||||||
self.initiallyClampedSlipnodes = [
|
self.initiallyClampedSlipnodes = [
|
||||||
|
|||||||
@ -23,7 +23,8 @@ class Workspace(object):
|
|||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<Workspace trying %s:%s::%s:?>' % (
|
return '<Workspace trying %s:%s::%s:?>' % (
|
||||||
self.initialString, self.modifiedString, self.targetString)
|
self.initialString, self.modifiedString, self.targetString,
|
||||||
|
)
|
||||||
|
|
||||||
def resetWithStrings(self, initial, modified, target):
|
def resetWithStrings(self, initial, modified, target):
|
||||||
self.targetString = target
|
self.targetString = target
|
||||||
@ -136,11 +137,10 @@ class Workspace(object):
|
|||||||
def slippages(self):
|
def slippages(self):
|
||||||
result = []
|
result = []
|
||||||
if self.changedObject and self.changedObject.correspondence:
|
if self.changedObject and self.changedObject.correspondence:
|
||||||
result = [m for m in
|
result = self.changedObject.correspondence.conceptMappings[:]
|
||||||
self.changedObject.correspondence.conceptMappings]
|
for o in self.initial.objects:
|
||||||
for objekt in self.initial.objects:
|
if o.correspondence:
|
||||||
if objekt.correspondence:
|
for mapping in o.correspondence.slippages():
|
||||||
for mapping in objekt.correspondence.slippages():
|
|
||||||
if not mapping.isNearlyContainedBy(result):
|
if not mapping.isNearlyContainedBy(result):
|
||||||
result += [mapping]
|
result += [mapping]
|
||||||
return result
|
return result
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
||||||
def __chooseObjectFromList(ctx, objects, attribute):
|
def __chooseObjectFromList(ctx, objects, attribute):
|
||||||
random = ctx.random
|
random = ctx.random
|
||||||
temperature = ctx.temperature
|
temperature = ctx.temperature
|
||||||
|
|||||||
Reference in New Issue
Block a user