From b16666e4d7cd5081bb1282ffbc89ee6d5344f4c5 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Mon, 17 Apr 2017 19:38:46 -0700 Subject: [PATCH] Demagic WorkspaceStructure. NFC. --- copycat/bond.py | 3 ++- copycat/coderack.py | 14 +++++--------- copycat/correspondence.py | 3 ++- copycat/description.py | 3 ++- copycat/replacement.py | 3 ++- copycat/rule.py | 3 ++- copycat/workspaceObject.py | 3 ++- copycat/workspaceStructure.py | 3 +-- 8 files changed, 18 insertions(+), 17 deletions(-) diff --git a/copycat/bond.py b/copycat/bond.py index 8df6634..7dcaf6c 100644 --- a/copycat/bond.py +++ b/copycat/bond.py @@ -5,7 +5,8 @@ class Bond(WorkspaceStructure): # pylint: disable=too-many-arguments def __init__(self, source, destination, bondCategory, bondFacet, sourceDescriptor, destinationDescriptor): - WorkspaceStructure.__init__(self) + from context import context as ctx + WorkspaceStructure.__init__(self, ctx) slipnet = self.ctx.slipnet self.source = source self.string = self.source.string diff --git a/copycat/coderack.py b/copycat/coderack.py index 63121c4..a721389 100644 --- a/copycat/coderack.py +++ b/copycat/coderack.py @@ -4,7 +4,12 @@ import random import codeletMethods import formulas +from bond import Bond from codelet import Codelet +from correspondence import Correspondence +from description import Description +from group import Group +from rule import Rule NUMBER_OF_BINS = 7 @@ -192,8 +197,6 @@ class Coderack(object): The new codelet has urgency a function of the degree of conceptual-depth of the descriptions in the rule """ - from rule import Rule - rule = Rule(facet, description, category, relation) rule.updateStrength() if description and relation: @@ -206,8 +209,6 @@ class Coderack(object): def proposeCorrespondence(self, initialObject, targetObject, conceptMappings, flipTargetObject, oldCodelet): - from correspondence import Correspondence - correspondence = Correspondence(initialObject, targetObject, conceptMappings, flipTargetObject) for mapping in conceptMappings: @@ -227,8 +228,6 @@ class Coderack(object): oldCodelet, urgency, correspondence) def proposeDescription(self, objekt, type_, descriptor, oldCodelet): - from description import Description - description = Description(objekt, type_, descriptor) descriptor.buffer = 100.0 urgency = type_.activation @@ -242,7 +241,6 @@ class Coderack(object): def proposeGroup(self, objects, bondList, groupCategory, directionCategory, bondFacet, oldCodelet): - from group import Group slipnet = self.ctx.slipnet bondCategory = groupCategory.getRelatedNode(slipnet.bondCategory) bondCategory.buffer = 100.0 @@ -255,8 +253,6 @@ class Coderack(object): def proposeBond(self, source, destination, bondCategory, bondFacet, sourceDescriptor, destinationDescriptor, oldCodelet): - from bond import Bond - bondFacet.buffer = 100.0 sourceDescriptor.buffer = 100.0 destinationDescriptor.buffer = 100.0 diff --git a/copycat/correspondence.py b/copycat/correspondence.py index b525d6a..1feacb7 100644 --- a/copycat/correspondence.py +++ b/copycat/correspondence.py @@ -7,7 +7,8 @@ import formulas class Correspondence(WorkspaceStructure): def __init__(self, objectFromInitial, objectFromTarget, conceptMappings, flipTargetObject): - WorkspaceStructure.__init__(self) + from context import context as ctx + WorkspaceStructure.__init__(self, ctx) self.objectFromInitial = objectFromInitial self.objectFromTarget = objectFromTarget self.conceptMappings = conceptMappings diff --git a/copycat/description.py b/copycat/description.py index 5f32521..aa1bf44 100644 --- a/copycat/description.py +++ b/copycat/description.py @@ -4,7 +4,8 @@ from workspaceStructure import WorkspaceStructure class Description(WorkspaceStructure): def __init__(self, workspaceObject, descriptionType, descriptor): - WorkspaceStructure.__init__(self) + from context import context as ctx + WorkspaceStructure.__init__(self, ctx) self.object = workspaceObject self.string = workspaceObject.string self.descriptionType = descriptionType diff --git a/copycat/replacement.py b/copycat/replacement.py index 562cac8..3f21c05 100644 --- a/copycat/replacement.py +++ b/copycat/replacement.py @@ -3,7 +3,8 @@ from workspaceStructure import WorkspaceStructure class Replacement(WorkspaceStructure): def __init__(self, objectFromInitial, objectFromModified, relation): - WorkspaceStructure.__init__(self) + from context import context as ctx + WorkspaceStructure.__init__(self, ctx) self.objectFromInitial = objectFromInitial self.objectFromModified = objectFromModified self.relation = relation diff --git a/copycat/rule.py b/copycat/rule.py index 90a72b9..c7cfb78 100644 --- a/copycat/rule.py +++ b/copycat/rule.py @@ -7,7 +7,8 @@ import formulas class Rule(WorkspaceStructure): def __init__(self, facet, descriptor, category, relation): - WorkspaceStructure.__init__(self) + from context import context as ctx + WorkspaceStructure.__init__(self, ctx) self.facet = facet self.descriptor = descriptor self.category = category diff --git a/copycat/workspaceObject.py b/copycat/workspaceObject.py index c5512b9..a5cf292 100644 --- a/copycat/workspaceObject.py +++ b/copycat/workspaceObject.py @@ -8,7 +8,8 @@ from workspaceStructure import WorkspaceStructure class WorkspaceObject(WorkspaceStructure): # pylint: disable=too-many-instance-attributes def __init__(self, workspaceString): - WorkspaceStructure.__init__(self) + from context import context as ctx + WorkspaceStructure.__init__(self, ctx) self.string = workspaceString self.descriptions = [] self.extrinsicDescriptions = [] diff --git a/copycat/workspaceStructure.py b/copycat/workspaceStructure.py index 3a2e76f..dfa68de 100644 --- a/copycat/workspaceStructure.py +++ b/copycat/workspaceStructure.py @@ -7,8 +7,7 @@ def abstract_call(objekt, name): class WorkspaceStructure(object): - def __init__(self): - from context import context as ctx + def __init__(self, ctx): self.ctx = ctx self.string = None self.internalStrength = 0.0