Skip to content

Commit 1f84881

Browse files
committed
Remove _multi_child... and create_many_to_many_relationship() since Neo no longer has any such relationships
1 parent 95420ee commit 1f84881

File tree

3 files changed

+7
-93
lines changed

3 files changed

+7
-93
lines changed

doc/source/images/generate_diagram.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ def get_rect_height(name, obj):
2828
nlines = 1.5
2929
nlines += len(getattr(obj, '_all_attrs', []))
3030
nlines += len(getattr(obj, '_single_child_objects', []))
31-
nlines += len(getattr(obj, '_multi_child_objects', []))
3231
return nlines * line_heigth
3332

3433

@@ -75,7 +74,6 @@ def generate_diagram(rect_pos, rect_width, figsize):
7574
for name, pos in rect_pos.items():
7675
obj = objs[name]
7776
relationships = [getattr(obj, '_single_child_objects', []),
78-
getattr(obj, '_multi_child_objects', []),
7977
getattr(obj, '_child_properties', [])]
8078

8179
for r in range(3):
@@ -122,16 +120,6 @@ def generate_diagram(rect_pos, rect_width, figsize):
122120
facecolor='c', edgecolor='k', alpha=.5)
123121
ax.add_patch(rect)
124122

125-
# multi relationship
126-
relationship = list(getattr(obj, '_multi_child_objects', []))
127-
pos2 = (pos[1] + htotal - line_heigth * (1.5 + len(relationship))
128-
- rect_height)
129-
rect_height = len(relationship) * line_heigth
130-
131-
rect = Rectangle((pos[0], pos2), rect_width, rect_height,
132-
facecolor='m', edgecolor='k', alpha=.5)
133-
ax.add_patch(rect)
134-
135123
# necessary attr
136124
pos2 = (pos[1] + htotal
137125
- line_heigth * (1.5 + len(allrelationship) + len(obj._necessary_attrs)))

neo/core/container.py

Lines changed: 7 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,6 @@ class Container(BaseNeo):
114114
class.__name__.lower()+'s' will be automatically
115115
defined to hold this child and will be
116116
initialized to an empty list.
117-
:_multi_child_objects: Neo container objects that can be children
118-
of this object. This attribute is used in
119-
cases where the child can have multiple
120-
parents of this type. An instance attribute
121-
named class.__name__.lower()+'s' will be
122-
automatically defined to hold this child and
123-
will be initialized to an empty list.
124117
:_child_properties: Properties that return sub-children of a particular
125118
type. These properties must still be defined.
126119
This is mostly used for generate_diagram.
@@ -134,25 +127,17 @@ class Container(BaseNeo):
134127
have one parent of this type.
135128
:_container_child_objects: +
136129
:_data_child_objects:
137-
:_child_objects: All child objects.
138-
:_single_child_objects: + :_multi_child_objects:
130+
:_child_objects: All child objects. Same as :_single_child_objects:
139131
:_container_child_containers: The names of the container attributes
140132
used to store :_container_child_objects:
141133
:_data_child_containers: The names of the container attributes used
142134
to store :_data_child_objects:
143135
:_single_child_containers: The names of the container attributes used
144136
to store :_single_child_objects:
145-
:_multi_child_containers: The names of the container attributes used
146-
to store :_multi_child_objects:
147-
:_child_containers: All child container attributes.
148-
:_single_child_containers: +
149-
:_multi_child_containers:
137+
:_child_containers: All child container attributes. Same as :_single_child_containers:
150138
:_single_children: All objects that are children of the current object
151139
where the child can only have one parent of
152140
this type.
153-
:_multi_children: All objects that are children of the current object
154-
where the child can have multiple parents of
155-
this type.
156141
:data_children: All data objects that are children of
157142
the current object.
158143
:container_children: All container objects that are children of
@@ -186,15 +171,7 @@ class Container(BaseNeo):
186171
single parent, set its parent
187172
to be the current object.
188173
189-
:create_many_to_many_relationship(**args): For children of the current
190-
object that can have more
191-
than one parent of this
192-
type, put the current
193-
object in the parent list.
194-
195-
:create_relationship(**args): Combines
196-
:create_many_to_one_relationship: and
197-
:create_many_to_many_relationship:
174+
:create_relationship(**args): Same as :create_many_to_one_relationship:
198175
199176
:merge(**args): Annotations are merged based on the rules of
200177
:merge_annotations:. Child objects with the same name
@@ -218,8 +195,6 @@ class Container(BaseNeo):
218195
_container_child_objects = ()
219196
# Child objects that have data and have a single parent
220197
_data_child_objects = ()
221-
# Child objects that can have multiple parents
222-
_multi_child_objects = ()
223198
# Properties returning children of children [of children...]
224199
_child_properties = ()
225200
# Containers that are listed when pretty-printing
@@ -265,27 +240,19 @@ def _single_child_containers(self):
265240
return tuple([_container_name(child) for child in
266241
self._single_child_objects])
267242

268-
@property
269-
def _multi_child_containers(self):
270-
"""
271-
Containers for child objects that can have multiple parents.
272-
"""
273-
return tuple([_container_name(child) for child in
274-
self._multi_child_objects])
275-
276243
@property
277244
def _child_objects(self):
278245
"""
279246
All types for child objects.
280247
"""
281-
return self._single_child_objects + self._multi_child_objects
248+
return self._single_child_objects
282249

283250
@property
284251
def _child_containers(self):
285252
"""
286253
All containers for child objects.
287254
"""
288-
return self._single_child_containers + self._multi_child_containers
255+
return self._single_child_containers
289256

290257
@property
291258
def _single_children(self):
@@ -296,15 +263,6 @@ def _single_children(self):
296263
self._single_child_containers]
297264
return tuple(sum(childs, []))
298265

299-
@property
300-
def _multi_children(self):
301-
"""
302-
All child objects that can have multiple parents.
303-
"""
304-
childs = [list(getattr(self, attr)) for attr in
305-
self._multi_child_containers]
306-
return tuple(sum(childs, []))
307-
308266
@property
309267
def data_children(self):
310268
"""
@@ -322,8 +280,7 @@ def container_children(self):
322280
Not recursive.
323281
"""
324282
childs = [list(getattr(self, attr)) for attr in
325-
self._container_child_containers +
326-
self._multi_child_containers]
283+
self._container_child_containers]
327284
return tuple(sum(childs, []))
328285

329286
@property
@@ -475,31 +432,6 @@ def create_many_to_one_relationship(self, force=False, recursive=True):
475432
child.create_many_to_one_relationship(force=force,
476433
recursive=True)
477434

478-
def create_many_to_many_relationship(self, append=True, recursive=True):
479-
"""
480-
For children of the current object that can have more than one parent
481-
of this type, put the current object in the parent list.
482-
483-
If append is True add it to the list, otherwise overwrite the list.
484-
If recursive is True descend into child objects and create
485-
relationships there
486-
"""
487-
parent_name = _container_name(self.__class__.__name__)
488-
for child in self._multi_children:
489-
if not hasattr(child, parent_name):
490-
continue
491-
if append:
492-
target = getattr(child, parent_name)
493-
if self not in target:
494-
target.append(self)
495-
continue
496-
setattr(child, parent_name, [self])
497-
498-
if recursive:
499-
for child in self.container_children:
500-
child.create_many_to_many_relationship(append=append,
501-
recursive=True)
502-
503435
def create_relationship(self, force=False, append=True, recursive=True):
504436
"""
505437
For each child of the current object that can only have a single
@@ -517,7 +449,6 @@ def create_relationship(self, force=False, append=True, recursive=True):
517449
relationships there
518450
"""
519451
self.create_many_to_one_relationship(force=force, recursive=False)
520-
self.create_many_to_many_relationship(append=append, recursive=False)
521452
if recursive:
522453
for child in self.container_children:
523454
child.create_relationship(force=force, append=append,
@@ -565,8 +496,7 @@ def merge(self, other):
565496
after the merge operation and should not be used further.
566497
"""
567498
# merge containers with the same name
568-
for container in (self._container_child_containers +
569-
self._multi_child_containers):
499+
for container in self._container_child_containers:
570500
lookup = {obj.name: obj for obj in getattr(self, container)}
571501
ids = [id(obj) for obj in getattr(self, container)]
572502
for obj in getattr(other, container):

neo/test/coretest/test_container.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ def test__children(self):
5656

5757
self.assertEqual(container._container_child_objects, ())
5858
self.assertEqual(container._data_child_objects, ())
59-
self.assertEqual(container._multi_child_objects, ())
6059
self.assertEqual(container._child_properties, ())
6160

6261
self.assertEqual(container._repr_pretty_containers, ())
@@ -66,12 +65,10 @@ def test__children(self):
6665
self.assertEqual(container._container_child_containers, ())
6766
self.assertEqual(container._data_child_containers, ())
6867
self.assertEqual(container._single_child_containers, ())
69-
self.assertEqual(container._multi_child_containers, ())
7068

7169
self.assertEqual(container._child_objects, ())
7270
self.assertEqual(container._child_containers, ())
7371

74-
self.assertEqual(container._multi_children, ())
7572
self.assertEqual(container._single_children, ())
7673
self.assertEqual(container.data_children, ())
7774
self.assertEqual(container.container_children, ())
@@ -95,7 +92,6 @@ def test__children(self):
9592
self.assertEqual(container.size, {})
9693

9794
container.create_many_to_one_relationship()
98-
container.create_many_to_many_relationship()
9995
container.create_relationship()
10096

10197
def test_filter(self):

0 commit comments

Comments
 (0)