MCPcopy Index your code
hub / github.com/PyTables/PyTables / _read_coordinates

Method _read_coordinates

tables/table.py:2086–2121  ·  view source on GitHub ↗

Private part of `read_coordinates()` with no flavor conversion.

(
        self, coords: np.ndarray, field: str | None = None
    )

Source from the content-addressed store, hash-verified

2084 return internal_to_flavor(arr, self.flavor)
2085
2086 def _read_coordinates(
2087 self, coords: np.ndarray, field: str | None = None
2088 ) -> np.ndarray:
2089 """Private part of `read_coordinates()` with no flavor conversion."""
2090 coords = self._point_selection(coords)
2091
2092 ncoords = len(coords)
2093 # Create a read buffer only if needed
2094 if field is None or ncoords > 0:
2095 # Doing a copy is faster when ncoords is small (<1000)
2096 if ncoords < min(1000, self.nrowsinbuf):
2097 result = self._v_iobuf[:ncoords].copy()
2098 else:
2099 result = self._get_container(ncoords)
2100
2101 # Do the real read
2102 if ncoords > 0:
2103 # Turn coords into an array of coordinate indexes, if necessary
2104 if not (
2105 isinstance(coords, np.ndarray)
2106 and coords.dtype.type is _npsizetype
2107 and coords.flags.contiguous
2108 and coords.flags.aligned
2109 ):
2110 # Get a contiguous and aligned coordinate array
2111 coords = np.array(coords, dtype=SizeType)
2112 self._read_elements(coords, result)
2113
2114 # Do the final conversions, if needed
2115 if field:
2116 if ncoords > 0:
2117 result = get_nested_field(result, field)
2118 else:
2119 # Get an empty array from the cache
2120 result = self._getemptyarray(self.coldtypes[field])
2121 return result
2122
2123 def read_coordinates(
2124 self, coords: np.ndarray, field: str | None = None

Callers 2

read_coordinatesMethod · 0.95
__getitem__Method · 0.95

Calls 4

_get_containerMethod · 0.95
_getemptyarrayMethod · 0.95
_point_selectionMethod · 0.80
copyMethod · 0.45

Tested by

no test coverage detected