Give WorkspaceString a self.ctx. Demagic all WorkspaceObjects. NFC.
This commit is contained in:
@ -11,7 +11,7 @@ from context import context
|
||||
context.slipnet = Slipnet()
|
||||
context.temperature = Temperature()
|
||||
context.coderack = Coderack(context)
|
||||
context.workspace = Workspace()
|
||||
context.workspace = Workspace(context)
|
||||
|
||||
|
||||
def run(initial, modified, target, iterations):
|
||||
|
||||
@ -12,8 +12,9 @@ def __adjustUnhappiness(values):
|
||||
|
||||
|
||||
class Workspace(object):
|
||||
def __init__(self):
|
||||
def __init__(self, ctx):
|
||||
#logging.debug('workspace.__init__()')
|
||||
self.ctx = ctx
|
||||
self.setStrings('', '', '')
|
||||
self.reset()
|
||||
self.totalUnhappiness = 0.0
|
||||
@ -36,9 +37,9 @@ class Workspace(object):
|
||||
self.objects = []
|
||||
self.structures = []
|
||||
self.rule = None
|
||||
self.initial = WorkspaceString(self.initialString)
|
||||
self.modified = WorkspaceString(self.modifiedString)
|
||||
self.target = WorkspaceString(self.targetString)
|
||||
self.initial = WorkspaceString(self.ctx, self.initialString)
|
||||
self.modified = WorkspaceString(self.ctx, self.modifiedString)
|
||||
self.target = WorkspaceString(self.ctx, self.targetString)
|
||||
|
||||
def assessUnhappiness(self):
|
||||
self.intraStringUnhappiness = __adjustUnhappiness(
|
||||
|
||||
@ -8,8 +8,7 @@ from workspaceStructure import WorkspaceStructure
|
||||
class WorkspaceObject(WorkspaceStructure):
|
||||
# pylint: disable=too-many-instance-attributes
|
||||
def __init__(self, workspaceString):
|
||||
from context import context as ctx
|
||||
WorkspaceStructure.__init__(self, ctx)
|
||||
WorkspaceStructure.__init__(self, workspaceString.ctx)
|
||||
self.string = workspaceString
|
||||
self.descriptions = []
|
||||
self.extrinsicDescriptions = []
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
import logging
|
||||
from group import Group
|
||||
from letter import Letter
|
||||
|
||||
|
||||
class WorkspaceString(object):
|
||||
def __init__(self, s):
|
||||
from context import context as ctx
|
||||
def __init__(self, ctx, s):
|
||||
slipnet = ctx.slipnet
|
||||
workspace = ctx.workspace
|
||||
self.ctx = ctx
|
||||
self.string = s
|
||||
self.bonds = []
|
||||
self.objects = []
|
||||
@ -76,8 +77,6 @@ class WorkspaceString(object):
|
||||
self.intraStringUnhappiness = total / len(self.objects)
|
||||
|
||||
def equivalentGroup(self, sought):
|
||||
from group import Group
|
||||
|
||||
for objekt in self.objects:
|
||||
if isinstance(objekt, Group):
|
||||
if objekt.sameGroup(sought):
|
||||
|
||||
Reference in New Issue
Block a user