MCPcopy Create free account
hub / github.com/pydata/xarray / _getitem

Method _getitem

xarray/backends/netCDF4_.py:121–141  ·  view source on GitHub ↗
(self, key)

Source from the content-addressed store, hash-verified

119 )
120
121 def _getitem(self, key):
122 if self.datastore.is_remote: # pragma: no cover
123 getitem = functools.partial(robust_getitem, catch=RuntimeError)
124 else:
125 getitem = operator.getitem
126
127 try:
128 with self.datastore.lock:
129 original_array = self.get_array(needs_lock=False)
130 array = getitem(original_array, key)
131 except IndexError as err:
132 # Catch IndexError in netCDF4 and return a more informative
133 # error message. This is most often called when an unsorted
134 # indexer is used before the data is loaded from disk.
135 msg = (
136 "The indexing operation you are attempting to perform "
137 "is not valid on netCDF4.Variable object. Try loading "
138 "your data into memory first by calling .load()."
139 )
140 raise IndexError(msg) from err
141 return array
142
143
144def _encode_nc4_variable(var, name=None):

Callers

nothing calls this directly

Calls 1

get_arrayMethod · 0.95

Tested by

no test coverage detected