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

Method _get_info

tables/expression.py:495–602  ·  view source on GitHub ↗

Return various info needed for evaluating the computation loop.

(
        self, shape: list[int], maindim: int | None, itermode: bool = False
    )

Source from the content-addressed store, hash-verified

493 return shape, maindim
494
495 def _get_info(
496 self, shape: list[int], maindim: int | None, itermode: bool = False
497 ) -> (
498 tuple[int, list[int], int, int, int | None, int]
499 | tuple[
500 int,
501 list[int],
502 int,
503 int,
504 int | None,
505 int,
506 ContainerType,
507 int,
508 int,
509 int,
510 int,
511 ]
512 ):
513 """Return various info needed for evaluating the computation loop."""
514 # Compute the shape of the resulting container having
515 # in account new possible values of start, stop and step in
516 # the inputs range
517 if maindim is not None:
518 start, stop, step = slice(
519 self.start, self.stop, self.step
520 ).indices(shape[maindim])
521 shape[maindim] = min(shape[maindim], len(range(start, stop, step)))
522 i_nrows = shape[maindim]
523 else:
524 start, stop, step = 0, 0, None
525 i_nrows = 0
526
527 if not itermode:
528 # Create a container for output if not defined yet
529 o_maindim = 0 # Default maindim
530 if self.out is None:
531 out = np.empty(shape, dtype=self._single_row_out.dtype)
532 # Get the trivial values for start, stop and step
533 if maindim is not None:
534 o_start, o_stop, o_step = (0, shape[maindim], 1)
535 else:
536 o_start, o_stop, o_step = (0, 0, 1)
537 else:
538 out = self.out
539 # Out container already provided. Do some sanity checks.
540 if hasattr(out, "maindim"):
541 o_maindim = out.maindim
542
543 # Refine the shape of the resulting container having in
544 # account new possible values of start, stop and step in
545 # the output range
546 o_shape = list(out.shape)
547 s = slice(self.o_start, self.o_stop, self.o_step)
548 o_start, o_stop, o_step = s.indices(o_shape[o_maindim])
549 o_shape[o_maindim] = min(
550 o_shape[o_maindim], len(range(o_start, o_stop, o_step))
551 )
552

Callers 3

evalMethod · 0.95
__iter__Method · 0.95
_g_openMethod · 0.80

Calls 2

_calc_nrowsinbufMethod · 0.95
popMethod · 0.80

Tested by

no test coverage detected