Skip to content

Commit

Permalink
changing the key functionality so that maps are returned when looking…
Browse files Browse the repository at this point in the history
… for single layers
  • Loading branch information
wafels committed Feb 13, 2015
1 parent ec400ea commit 41bd62f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions sunpy/map/mapcube.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,14 @@ def __init__(self, *args, **kwargs):
self._derotate()

def __getitem__(self, key):
"""Overriding indexing operation. Returns a mapcube."""
return MapCube(self.maps[key])
"""Overriding indexing operation. If the key results in a single map,
then a map object is returned. This allows functions like enumerate to
work. Otherwise, a mapcube is returned."""

if isinstance(self.maps[key], GenericMap):
return self.maps[key]
else:
return MapCube(self.maps[key])

def __len__(self):
"""Return the number of maps in a mapcube."""
Expand Down

0 comments on commit 41bd62f

Please sign in to comment.