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

Method read

tables/array.py:895–938  ·  view source on GitHub ↗

Get data in the array as an object of the current flavor. The start, stop and step parameters can be used to select only a *range of rows* in the array. Their meanings are the same as in the built-in range() Python function, except that negative values of step are n

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

Source from the content-addressed store, hash-verified

893 return arr
894
895 def read(
896 self,
897 start: int | None = None,
898 stop: int | None = None,
899 step: int | None = None,
900 out: np.ndarray | None = None,
901 ) -> np.ndarray:
902 """Get data in the array as an object of the current flavor.
903
904 The start, stop and step parameters can be used to select only a
905 *range of rows* in the array. Their meanings are the same as in
906 the built-in range() Python function, except that negative values
907 of step are not allowed yet. Moreover, if only start is specified,
908 then stop will be set to start + 1. If you do not specify neither
909 start nor stop, then *all the rows* in the array are selected.
910
911 The out parameter may be used to specify a NumPy array to receive
912 the output data. Note that the array must have the same size as
913 the data selected with the other parameters. Note that the array's
914 datatype is not checked and no type casting is performed, so if it
915 does not match the datatype on disk, the output will not be correct.
916 Also, this parameter is only valid when the array's flavor is set
917 to 'numpy'. Otherwise, a TypeError will be raised.
918
919 When data is read from disk in NumPy format, the output will be
920 in the current system's byteorder, regardless of how it is stored
921 on disk.
922 The exception is when an output buffer is supplied, in which case
923 the output will be in the byteorder of that output buffer.
924
925 .. versionchanged:: 3.0
926 Added the *out* parameter.
927
928 """
929 self._g_check_open()
930 if out is not None and self.flavor != "numpy":
931 msg = (
932 f"Optional 'out' argument may only be supplied if array "
933 f"flavor is 'numpy', currently is {self.flavor}"
934 )
935 raise TypeError(msg)
936 start, stop, step = self._process_range_read(start, stop, step)
937 arr = self._read(start, stop, step, out)
938 return internal_to_flavor(arr, self.flavor)
939
940 def _g_copy_with_stats(
941 self,

Callers

nothing calls this directly

Calls 4

_readMethod · 0.95
internal_to_flavorFunction · 0.85
_g_check_openMethod · 0.80
_process_range_readMethod · 0.80

Tested by

no test coverage detected