@@ -240,67 +240,6 @@ def extend(self, elements):
240
240
241
241
self .finalize_append ()
242
242
243
- def _extend_using_coroutine (self , buffer_size = 4 ):
244
- """ Creates a coroutine allowing to append elements.
245
-
246
- Parameters
247
- ----------
248
- buffer_size : float, optional
249
- Size (in Mb) for memory pre-allocation.
250
-
251
- Returns
252
- -------
253
- coroutine
254
- Coroutine object which expects the values to be appended to this
255
- array sequence.
256
-
257
- Notes
258
- -----
259
- This method is essential for
260
- :func:`create_arraysequences_from_generator` as it allows for an
261
- efficient way of creating multiple array sequences in a hyperthreaded
262
- fashion and still benefit from the memory buffering. Whitout this
263
- method the alternative would be to use :meth:`append` which does
264
- not have such buffering mechanism and thus is at least one order of
265
- magnitude slower.
266
- """
267
- offsets = []
268
- lengths = []
269
-
270
- offset = self ._get_next_offset ()
271
- try :
272
- first_element = True
273
- while True :
274
- e = (yield )
275
- e = np .asarray (e )
276
- if first_element :
277
- first_element = False
278
- n_rows_buffer = int (buffer_size * 1024 ** 2 // e .nbytes )
279
- new_shape = (n_rows_buffer ,) + e .shape [1 :]
280
- if len (self ) == 0 :
281
- self ._data = np .empty (new_shape , dtype = e .dtype )
282
-
283
- end = offset + len (e )
284
- if end > len (self ._data ):
285
- # Resize needed, adding `len(e)` items plus some buffer.
286
- nb_points = len (self ._data )
287
- nb_points += len (e ) + n_rows_buffer
288
- self ._data .resize ((nb_points ,) + self .common_shape )
289
-
290
- offsets .append (offset )
291
- lengths .append (len (e ))
292
- self ._data [offset :offset + len (e )] = e
293
- offset += len (e )
294
-
295
- except GeneratorExit :
296
- pass
297
-
298
- self ._offsets = np .r_ [self ._offsets , offsets ].astype (np .intp )
299
- self ._lengths = np .r_ [self ._lengths , lengths ].astype (np .intp )
300
-
301
- # Clear unused memory.
302
- self ._data .resize ((offset ,) + self .common_shape )
303
-
304
243
def copy (self ):
305
244
""" Creates a copy of this :class:`ArraySequence` object.
306
245
0 commit comments