Evaluate the expression and return the outcome. Because of performance reasons, the computation order tries to go along the common main dimension of all inputs. If not such a common main dimension is found, the iteration will go along the leading dimension instead.
(self)
| 602 | return (i_nrows, slice_pos, start, stop, step, nrowsinbuf) |
| 603 | |
| 604 | def eval(self) -> ContainerType: # noqa: A003 |
| 605 | """Evaluate the expression and return the outcome. |
| 606 | |
| 607 | Because of performance reasons, the computation order tries to go along |
| 608 | the common main dimension of all inputs. If not such a common main |
| 609 | dimension is found, the iteration will go along the leading dimension |
| 610 | instead. |
| 611 | |
| 612 | For non-consistent shapes in inputs (i.e. shapes having a different |
| 613 | number of dimensions), the regular NumPy broadcast rules applies. |
| 614 | There is one exception to this rule though: when the dimensions |
| 615 | orthogonal to the main dimension of the expression are consistent, but |
| 616 | the main dimension itself differs among the inputs, then the shortest |
| 617 | one is chosen for doing the computations. This is so because trying to |
| 618 | expand very large on-disk arrays could be too expensive or simply not |
| 619 | possible. |
| 620 | |
| 621 | Also, the regular Numexpr casting rules (which are similar to those of |
| 622 | NumPy, although you should check the Numexpr manual for the exceptions) |
| 623 | are applied to determine the output type. |
| 624 | |
| 625 | Finally, if the set_output() method specifying a user container has |
| 626 | already been called, the output is sent to this user-provided |
| 627 | container. If not, a fresh NumPy container is returned instead. |
| 628 | |
| 629 | .. warning:: |
| 630 | |
| 631 | When dealing with large on-disk inputs, failing to specify an |
| 632 | on-disk container may consume all your available memory. |
| 633 | |
| 634 | """ |
| 635 | values, shape, maindim = self.values, self.shape, self.maindim |
| 636 | |
| 637 | # Get different info we need for the main computation loop |
| 638 | ( |
| 639 | i_nrows, |
| 640 | slice_pos, |
| 641 | start, |
| 642 | stop, |
| 643 | step, |
| 644 | nrowsinbuf, |
| 645 | out, |
| 646 | o_maindim, |
| 647 | o_start, |
| 648 | o_stop, |
| 649 | o_step, |
| 650 | ) = self._get_info(shape, maindim) |
| 651 | |
| 652 | if i_nrows == 0: |
| 653 | # No elements to compute |
| 654 | if start >= stop and self.start is not None: |
| 655 | return out |
| 656 | else: |
| 657 | return self._single_row_out |
| 658 | |
| 659 | # Create a key that selects every element in inputs and output |
| 660 | # (including the main dimension) |
| 661 | i_slices = [slice(None)] * (maindim + 1) |