MCPcopy Create free account
hub / github.com/PyTables/PyTables / _g_copy_with_stats

Method _g_copy_with_stats

tables/earray.py:240–293  ·  view source on GitHub ↗

Private part of Leaf.copy() for each kind of leaf.

(
        self,
        group: Group,
        name: str,
        start: int,
        stop: int,
        step: int,
        title: str,
        filters: Filters | None,
        chunkshape: tuple[int, ...] | None,
        _log: bool,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

238 self._append(nparr)
239
240 def _g_copy_with_stats(
241 self,
242 group: Group,
243 name: str,
244 start: int,
245 stop: int,
246 step: int,
247 title: str,
248 filters: Filters | None,
249 chunkshape: tuple[int, ...] | None,
250 _log: bool,
251 **kwargs,
252 ) -> tuple[EArray, int]:
253 """Private part of Leaf.copy() for each kind of leaf."""
254 start, stop, step = self._process_range_read(start, stop, step)
255 # Build the new EArray object
256 maindim = self.maindim
257 shape = list(self.shape)
258 shape[maindim] = 0
259 # The number of final rows
260 nrows = len(range(start, stop, step))
261 # Build the new EArray object
262 obj = EArray(
263 group,
264 name,
265 atom=self.atom,
266 shape=shape,
267 title=title,
268 filters=filters,
269 expectedrows=nrows,
270 chunkshape=chunkshape,
271 _log=_log,
272 )
273 # Now, fill the new earray with values from source
274 nrowsinbuf = self.nrowsinbuf
275 # The slices parameter for self.__getitem__
276 slices = [slice(0, dim, 1) for dim in self.shape]
277 # This is a hack to prevent doing unnecessary conversions
278 # when copying buffers
279 self._v_convert = False
280 # Start the copy itself
281 for start2 in range(start, stop, step * nrowsinbuf):
282 # Save the records on disk
283 stop2 = start2 + step * nrowsinbuf
284 if stop2 > stop:
285 stop2 = stop
286 # Set the proper slice in the extensible dimension
287 slices[maindim] = slice(start2, stop2, step)
288 obj._append(self.__getitem__(tuple(slices)))
289 # Active the conversion again (default)
290 self._v_convert = True
291 nbytes = np.prod(self.shape, dtype=SizeType) * self.atom.itemsize
292
293 return (obj, nbytes)

Callers

nothing calls this directly

Calls 3

EArrayClass · 0.85
_process_range_readMethod · 0.80
__getitem__Method · 0.45

Tested by

no test coverage detected