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

Method _read

tables/array.py:861–893  ·  view source on GitHub ↗

Read the array from disk without slice or flavor processing.

(
        self, start: int, stop: int, step: int, out: np.ndarray | None = None
    )

Source from the content-addressed store, hash-verified

859 self._g_write_selection(selection, nparr)
860
861 def _read(
862 self, start: int, stop: int, step: int, out: np.ndarray | None = None
863 ) -> np.ndarray:
864 """Read the array from disk without slice or flavor processing."""
865 nrowstoread = len(range(start, stop, step))
866 shape = list(self.shape)
867 if shape:
868 shape[self.maindim] = nrowstoread
869 if out is None:
870 arr = np.empty(dtype=self.atom.dtype, shape=shape)
871 else:
872 bytes_required = self.rowsize * nrowstoread
873 # if buffer is too small, it will segfault
874 if bytes_required != out.nbytes:
875 raise ValueError(
876 f"output array size invalid, got {out.nbytes}"
877 f" bytes, need {bytes_required} bytes"
878 )
879 if not out.flags["C_CONTIGUOUS"]:
880 raise ValueError("output array not C contiguous")
881 arr = out
882 # Protection against reading empty arrays
883 if 0 not in shape:
884 # Arrays that have non-zero dimensionality
885 self._read_array(start, stop, step, arr)
886 # data is always read in the system byteorder
887 # if the out array's byteorder is different, do a byteswap
888 if (
889 out is not None
890 and byteorders[arr.dtype.byteorder] != sys.byteorder
891 ):
892 arr.byteswap(True)
893 return arr
894
895 def read(
896 self,

Callers 2

__next__Method · 0.95
readMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected