Commit 33eeb4be authored by Kris Vanneste's avatar Kris Vanneste
Browse files

Allowed 'index' argument of __getitem__ method to be integer list or array.

git-svn-id: https://svn.seismo.oma.be/svn/seismo/mapping/layeredbasemap/trunk@7565 40b490c5-b4d9-47cb-8714-9bef99b524d5
parent 99b23456
......@@ -198,14 +198,29 @@ class MultiPointData(MultiData):
self.style_params = style_params or {}
def __getitem__(self, index):
lon = self.lons[index]
lat = self.lats[index]
z = self.z[index]
value = self._get_value_at_index(index)
label = self._get_label_at_index(index)
style_params = self._get_style_params_at_index(index)
return PointData(lon, lat, z=z, value=value, label=label,
style_params=style_params)
"""
:param index:
int or list or array of ints
"""
if np.isscalar(index):
lon = self.lons[index]
lat = self.lats[index]
z = self.z[index]
value = self._get_value_at_index(index)
label = self._get_label_at_index(index)
style_params = self._get_style_params_at_index(index)
return PointData(lon, lat, z=z, value=value, label=label,
style_params=style_params)
else:
idxs = np.asarray(index)
lons = self.lons[idxs]
lats = self.lats[idxs]
z = [self.z[index] for index in idxs]
values = self._get_values_at_indexes(idxs)
labels = self._get_labels_at_indexes(idxs)
style_params = self._get_style_params_at_indexes(idxs)
return MultiPointData(lons, lats, z=z, values=values, labels=labels,
style_params=style_params)
@classmethod
def from_points(cls, point_list):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment