Skip to content

Commit 006c97b

Browse files
committed
create_many_to_one_relationship() is now just create_relationship()
1 parent 1f84881 commit 006c97b

27 files changed

+49
-97
lines changed

examples/generated_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def generate_block(n_segments=3, n_channels=4, n_units=3,
5656
seg.spiketrains.append(train)
5757
u.spiketrains.append(train)
5858

59-
block.create_many_to_one_relationship()
59+
block.create_relationship()
6060
return block
6161

6262

neo/core/container.py

Lines changed: 10 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,9 @@ class Container(BaseNeo):
166166
object recursively that are of a
167167
particular class.
168168
169-
:create_many_to_one_relationship(**args): For each child of the current
170-
object that can only have a
171-
single parent, set its parent
172-
to be the current object.
173-
174-
:create_relationship(**args): Same as :create_many_to_one_relationship:
169+
:create_relationship(**args): For each child of the current
170+
object, set its parent
171+
to be the current object.
175172
176173
:merge(**args): Annotations are merged based on the rules of
177174
:merge_annotations:. Child objects with the same name
@@ -209,7 +206,7 @@ def __init__(self, name=None, description=None, file_origin=None,
209206
file_origin=file_origin, **annotations)
210207

211208
@property
212-
def _single_child_objects(self):
209+
def _child_objects(self):
213210
"""
214211
Child objects that have a single parent.
215212
"""
@@ -233,34 +230,20 @@ def _data_child_containers(self):
233230
self._data_child_objects])
234231

235232
@property
236-
def _single_child_containers(self):
233+
def _child_containers(self):
237234
"""
238235
Containers for child objects with a single parent.
239236
"""
240237
return tuple([_container_name(child) for child in
241-
self._single_child_objects])
242-
243-
@property
244-
def _child_objects(self):
245-
"""
246-
All types for child objects.
247-
"""
248-
return self._single_child_objects
249-
250-
@property
251-
def _child_containers(self):
252-
"""
253-
All containers for child objects.
254-
"""
255-
return self._single_child_containers
238+
self._child_objects])
256239

257240
@property
258241
def _single_children(self):
259242
"""
260243
All child objects that can only have single parents.
261244
"""
262245
childs = [list(getattr(self, attr)) for attr in
263-
self._single_child_containers]
246+
self._child_containers]
264247
return tuple(sum(childs, []))
265248

266249
@property
@@ -405,18 +388,11 @@ def list_children_by_class(self, cls):
405388
objs.extend(getattr(child, container_name, []))
406389
return objs
407390

408-
def create_many_to_one_relationship(self, force=False, recursive=True):
391+
def create_relationship(self, force=False, recursive=True):
409392
"""
410393
For each child of the current object that can only have a single
411394
parent, set its parent to be the current object.
412-
413-
Usage:
414-
>>> a_block.create_many_to_one_relationship()
415-
>>> a_block.create_many_to_one_relationship(force=True)
416-
417-
If the current object is a :class:`Block`, you want to run
418-
populate_RecordingChannel first, because this will create new objects
419-
that this method will link up.
395+
For children of the current object, put the current object in the parent list.
420396
421397
If force is True overwrite any existing relationships
422398
If recursive is True descend into child objects and create
@@ -429,30 +405,7 @@ def create_many_to_one_relationship(self, force=False, recursive=True):
429405
setattr(child, parent_name, self)
430406
if recursive:
431407
for child in self.container_children:
432-
child.create_many_to_one_relationship(force=force,
433-
recursive=True)
434-
435-
def create_relationship(self, force=False, append=True, recursive=True):
436-
"""
437-
For each child of the current object that can only have a single
438-
parent, set its parent to be the current object.
439-
For children of the current object that can have more than one parent
440-
of this type, put the current object in the parent list.
441-
442-
If the current object is a :class:`Block`, you want to run
443-
populate_RecordingChannel first, because this will create new objects
444-
that this method will link up.
445-
446-
If force is True overwrite any existing relationships
447-
If append is True add it to the list, otherwise overwrite the list.
448-
If recursive is True descend into child objects and create
449-
relationships there
450-
"""
451-
self.create_many_to_one_relationship(force=force, recursive=False)
452-
if recursive:
453-
for child in self.container_children:
454-
child.create_relationship(force=force, append=append,
455-
recursive=True)
408+
child.create_relationship(force=force, recursive=True)
456409

457410
def __deepcopy__(self, memo):
458411
"""

neo/io/asciisignalio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def read_segment(self, lazy=False):
292292
name='Column %d' % i)
293293
seg.analogsignals.append(ana_sig)
294294

295-
seg.create_many_to_one_relationship()
295+
seg.create_relationship()
296296
return seg
297297

298298
def read_metadata(self):

neo/io/asciispiketrainio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def read_segment(self,
107107
sptr.annotate(channel_index=i)
108108
seg.spiketrains.append(sptr)
109109

110-
seg.create_many_to_one_relationship()
110+
seg.create_relationship()
111111
return seg
112112

113113
def write_segment(self, segment,

neo/io/basefromrawio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def read_block(self, block_index=0, lazy=False,
178178
for c, sptr in enumerate(seg.spiketrains):
179179
st_groups[c].add(sptr)
180180

181-
bl.create_many_to_one_relationship()
181+
bl.create_relationship()
182182

183183
return bl
184184

@@ -278,7 +278,7 @@ def read_segment(self, block_index=0, seg_index=0, lazy=False,
278278
e.segment = seg
279279
seg.epochs.append(e)
280280

281-
seg.create_many_to_one_relationship()
281+
seg.create_relationship()
282282
return seg
283283

284284
def get_sub_signal_streams(self, signal_group_mode='group-by-same-units'):

neo/io/baseio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def read(self, lazy=False, **kargs):
126126
bl = Block(name='One segment only')
127127
seg = self.read_segment(lazy=lazy, **kargs)
128128
bl.segments.append(seg)
129-
bl.create_many_to_one_relationship()
129+
bl.create_relationship()
130130
return [bl]
131131
else:
132132
raise NotImplementedError

neo/io/brainwaredamio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def read_block(self, lazy=False, **kargs):
129129

130130
# create the objects to store other objects
131131
gr = Group(file_origin=self._filename)
132-
132+
133133
# load objects into their containers
134134
block.groups.append(gr)
135135

@@ -149,7 +149,7 @@ def read_block(self, lazy=False, **kargs):
149149
# remove the file object
150150
self._fsrc = None
151151

152-
block.create_many_to_one_relationship()
152+
block.create_relationship()
153153
return block
154154

155155
# -------------------------------------------------------------------------

neo/io/brainwaref32io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def read_block(self, lazy=False, **kargs):
158158
while res:
159159
res = self.__read_id()
160160

161-
block.create_many_to_one_relationship()
161+
block.create_relationship()
162162

163163
# cleanup attributes
164164
self._fsrc = None

neo/io/brainwaresrcio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ def read_next_block(self, **kargs):
279279
raise
280280

281281
# since we read at a Block level we always do this
282-
self._blk.create_many_to_one_relationship()
282+
self._blk.create_relationship()
283283

284284
# put the Block in a local object so it can be gargabe collected
285285
blockobj = self._blk

neo/io/klustakwikio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def read_block(self, lazy=False):
181181
u.add(st)
182182
seg.spiketrains.append(st)
183183

184-
block.create_many_to_one_relationship()
184+
block.create_relationship()
185185
return block
186186

187187
# Helper hidden functions for reading

0 commit comments

Comments
 (0)