def __getitem__(self, key):
        """Evaluates DynamicMap with specified key.

        Indexing into a DynamicMap evaluates the dynamic function with
        the specified key unless the key and corresponding value are
        already in the cache. This may also be used to evaluate
        multiple keys or even a cross-product of keys if a list of
        values per Dimension are defined. Once values are in the cache
        the DynamicMap can be cast to a HoloMap.

        Args:
            key: n-dimensional key corresponding to the key dimensions
               Scalar values will be evaluated as normal while lists
               of values will be combined to form the cross-product,
               making it possible to evaluate many keys at once.

        Returns:
            Returns evaluated callback return value for scalar key
            otherwise returns cloned DynamicMap containing the cross-
            product of evaluated items.
        """
        # Split key dimensions and data slices
        sample = False
        if key is Ellipsis:
            return self
        elif isinstance(key, (list, set)) and all(isinstance(v, tuple) for v in key):
            map_slice, data_slice = key, ()
            sample = True
        else:
            map_slice, data_slice = self._split_index(key)
        tuple_key = util.wrap_tuple_streams(map_slice, self.kdims, self.streams)

        # Validation
        if not sample:
            sliced = self._slice_bounded(tuple_key, data_slice)
            if sliced is not None:
                return sliced

        # Cache lookup
        try:
            dimensionless = util.dimensionless_contents(get_nested_streams(self),
                                                        self.kdims, no_duplicates=False)
            empty = util.stream_parameters(self.streams) == [] and self.kdims==[]
            if dimensionless or empty:
                raise KeyError('Using dimensionless streams disables DynamicMap cache')
            cache = super(DynamicMap,self).__getitem__(key)
        except KeyError:
            cache = None

        # If the key expresses a cross product, compute the elements and return
        product = self._cross_product(tuple_key, cache.data if cache else {}, data_slice)
        if product is not None:
            return product

        # Not a cross product and nothing cached so compute element.
        if cache is not None: return cache
        val = self._execute_callback(*tuple_key)
        if data_slice:
            val = self._dataslice(val, data_slice)
        self._cache(tuple_key, val)
        return val
def __getitem__ ( self , key ) : sample = False if key is Ellipsis : return self elif isinstance ( key , ( list , set ) ) and all ( isinstance ( v , tuple ) for v in key ) : map_slice , data_slice = key , ( ) sample = True else : map_slice , data_slice = self . _split_index ( key ) tuple_key = util . wrap_tuple_streams ( map_slice , self . kdims , self . streams ) if not sample : sliced = self . _slice_bounded ( tuple_key , data_slice ) if sliced is not None : return sliced try : dimensionless = util . dimensionless_contents ( get_nested_streams ( self ) , self . kdims , no_duplicates = False ) empty = util . stream_parameters ( self . streams ) == [ ] and self . kdims == [ ] if dimensionless or empty : raise KeyError ( 'Using dimensionless streams disables DynamicMap cache' ) cache = super ( DynamicMap , self ) . __getitem__ ( key ) except KeyError : cache = None product = self . _cross_product ( tuple_key , cache . data if cache else { } , data_slice ) if product is not None : return product if cache is not None : return cache val = self . _execute_callback ( * tuple_key ) if data_slice : val = self . _dataslice ( val , data_slice ) self . _cache ( tuple_key , val ) return val
Evaluates DynamicMap with specified key.

        Indexing into a DynamicMap evaluates the dynamic function with
        the specified key unless the key and corresponding value are
        already in the cache. This may also be used to evaluate
        multiple keys or even a cross-product of keys if a list of
        values per Dimension are defined. Once values are in the cache
        the DynamicMap can be cast to a HoloMap.

        Args:
            key: n-dimensional key corresponding to the key dimensions
               Scalar values will be evaluated as normal while lists
               of values will be combined to form the cross-product,
               making it possible to evaluate many keys at once.

        Returns:
            Returns evaluated callback return value for scalar key
            otherwise returns cloned DynamicMap containing the cross-
            product of evaluated items.