Get data in the array as a list of objects of the current flavor. Please note that, as the lengths of the different rows are variable, the returned value is a *Python list* (not an array of the current flavor), with as many entries as specified rows in the range para
(
self,
start: int | None = None,
stop: int | None = None,
step: int = 1,
)
| 808 | |
| 809 | # Accessor for the _read_array method in superclass |
| 810 | def read( |
| 811 | self, |
| 812 | start: int | None = None, |
| 813 | stop: int | None = None, |
| 814 | step: int = 1, |
| 815 | ) -> list: |
| 816 | """Get data in the array as a list of objects of the current flavor. |
| 817 | |
| 818 | Please note that, as the lengths of the different rows are variable, |
| 819 | the returned value is a *Python list* (not an array of the current |
| 820 | flavor), with as many entries as specified rows in the range |
| 821 | parameters. |
| 822 | |
| 823 | The start, stop and step parameters can be used to select only a |
| 824 | *range of rows* in the array. Their meanings are the same as in |
| 825 | the built-in range() Python function, except that negative values |
| 826 | of step are not allowed yet. Moreover, if only start is specified, |
| 827 | then stop will be set to start + 1. If you do not specify neither |
| 828 | start nor stop, then *all the rows* in the array are selected. |
| 829 | |
| 830 | """ |
| 831 | self._g_check_open() |
| 832 | start, stop, step = self._process_range_read(start, stop, step) |
| 833 | if start == stop: |
| 834 | listarr = [] |
| 835 | else: |
| 836 | listarr = self._read_array(start, stop, step) |
| 837 | |
| 838 | atom = self.atom |
| 839 | if not hasattr(atom, "size"): # it is a pseudo-atom |
| 840 | outlistarr = [atom.fromarray(arr) for arr in listarr] |
| 841 | else: |
| 842 | # Convert the list to the right flavor |
| 843 | flavor = self.flavor |
| 844 | outlistarr = [internal_to_flavor(arr, flavor) for arr in listarr] |
| 845 | return outlistarr |
| 846 | |
| 847 | def _read_coordinates(self, coords: Sequence[int]) -> list[list]: |
| 848 | """Read rows specified in `coords`.""" |
no test coverage detected