pop dimensions
        :parameter dimlist: list of dimensions
        :return: popped dimensions (tuple)
        
        .. note: overrides :func:`OrderedDict.pop`
19034
def pop(self,*args):
        '''
        
        '''
        nargs=len(args)
        dimlist=args[0] if isiterable(args[0]) else [args[0]]
        missing=args[1] if nargs > 1 else None 
        out=()
        for d in dimlist:
            out+=(super(dimStr, self).pop(d,missing),)
            if out[-1] == missing : self.set_ndims()
        
        return out if len(out) > 1 else out[0]
273209
def values(self):
        
        return [
            (
                np.array(dim.numeric_values)
                if (dim.numeric_values and any(~np.isnan(dim.numeric_values)))
                else None
            )
            for dim in self._slice.dimensions
        ]
936214
def convert_to_dimension(d):
  
  if d is None:
    return None
  if isinstance(d, Dimension):
    if not isinstance(d.name, str) or not isinstance(d.size, int):
      raise ValueError("Bad dimension %s" % (d,))
    return d
  name, size = d
  if isinstance(name, str) and isinstance(size, int):
    return Dimension(name, size)
  else:
    raise ValueError("could not convert %s to Dimension" % (d,))
1286472
def dimension_name(dimension):
    
    if isinstance(dimension, Dimension):
        return dimension.name
    elif isinstance(dimension, basestring):
        return dimension
    elif isinstance(dimension, tuple):
        return dimension[0]
    elif isinstance(dimension, dict):
        return dimension['name']
    elif dimension is None:
        return None
    else:
        raise ValueError('%s type could not be interpreted as Dimension. '
                         'Dimensions must be declared as a string, tuple, '
                         'dictionary or Dimension type.'
                         % type(dimension).__name__)
1289700
def POP(self, params):
        
        # TODO verify pop order
        # TODO pop list is comma separate, right?
        # TODO what registeres are allowed to POP to? Low Registers and PC
        # TODO need to support ranges, ie {R2, R5-R7}
        # TODO PUSH should reverse the list, not POP
        RPopList = self.get_one_parameter(r'\s*{(.*)}(.*)', params).split(',')
        RPopList.reverse()
        RPopList = [i.strip() for i in RPopList]

        def POP_func():
            for register in RPopList:
                # Get 4 bytes
                value = 0
                for i in range(4):
                    # TODO use memory width instead of constants
                    value |= self.memory[self.register['SP'] + i] << (8 * i)

                self.register[register] = value
                self.register['SP'] += 4

        return POP_func
793377
def drop_dimension(self, dimensions):
        
        dimensions = [dimensions] if np.isscalar(dimensions) else dimensions
        dims = [d for d in self.kdims if d not in dimensions]
        dim_inds = [self.get_dimension_index(d) for d in dims]
        key_getter = itemgetter(*dim_inds)
        return self.clone([(key_getter(k), v) for k, v in self.data.items()],
                          kdims=dims)
926162
def calculate_dimensions(variables):
    
    dims = OrderedDict()
    last_used = {}
    scalar_vars = set(k for k, v in variables.items() if not v.dims)
    for k, var in variables.items():
        for dim, size in zip(var.dims, var.shape):
            if dim in scalar_vars:
                raise ValueError('dimension %r already exists as a scalar '
                                 'variable' % dim)
            if dim not in dims:
                dims[dim] = size
                last_used[dim] = k
            elif dims[dim] != size:
                raise ValueError('conflicting sizes for dimension %r: '
                                 'length %s on %r and length %s on %r' %
                                 (dim, size, k, dims[dim], last_used[dim]))
    return dims
390327
def split(self):
        
        x = self.__class__()
        y = self.__class__()
        for dim, val in self.items():
            if isinstance(val, tuple):
                x[dim] = val[0]
                y[dim] = val[1]
            else:
                x[dim] = val
                y[dim] = val
        return x, y
1273852
def get_continuous_dims(self):
        
        continuous_dims = []
        for i in range(self.dimensionality):
            if self.space_expanded[i].type == 'continuous':
                continuous_dims += [i]
        return continuous_dims
3277
def red_dim(self, array):
        
        while isinstance(array, list) == True or \
        isinstance(array, np.ndarray) == True:
            try:
                if len(array) == 1:
                    array = array[0]
                else:
                    break
            except:
                break

        return array
979671
def _add_item(self, dim_vals, data, sort=True, update=True):
        
        sort = sort and self.sort
        if not isinstance(dim_vals, tuple):
            dim_vals = (dim_vals,)

        self._item_check(dim_vals, data)

        # Apply dimension types
        dim_types = zip([kd.type for kd in self.kdims], dim_vals)
        dim_vals = tuple(v if None in [t, v] else t(v) for t, v in dim_types)
        valid_vals = zip(self.kdims, dim_vals)

        for dim, val in valid_vals:
            if dim.values and val is not None and val not in dim.values:
                raise KeyError('%s dimension value %s not in'
                               ' specified dimension values.' % (dim, repr(val)))

        # Updates nested data structures rather than simply overriding them.
        if (update and (dim_vals in self.data)
            and isinstance(self.data[dim_vals], (MultiDimensionalMapping, OrderedDict))):
            self.data[dim_vals].update(data)
        else:
            self.data[dim_vals] = data

        if sort:
            self._resort()
402464
def dimensionNames(self):
        
        nSubDims = len(self._subArrayShape)
        subArrayDims = ['SubDim{}'.format(dimNr) for dimNr in range(nSubDims)]
        return list(self._ncVar.dimensions + tuple(subArrayDims))
85562
def with_dimensions(self, *dimensions):
    """"""
    self.dimensions = tuple(
        self._maybe_make_dimension(dim) for dim in dimensions)
    self._cached = None
    return self
63050
def unbound_dimensions(streams, kdims, no_duplicates=True):
    
    params = stream_parameters(streams, no_duplicates)
    return [d for d in kdims if d not in params]
1214607
def on_separate_dimensions(self):
        
        if np.any([isinstance(k.active_dims, slice) for k in self.kernels]):
            # Be conservative in the case of a slice object
            return False
        else:
            dimlist = [k.active_dims for k in self.kernels]
            overlapping = False
            for i, dims_i in enumerate(dimlist):
                for dims_j in dimlist[i + 1:]:
                    if np.any(dims_i.reshape(-1, 1) == dims_j.reshape(1, -1)):
                        overlapping = True
            return not overlapping
958897
def get_discrete_dims(self):
        
        discrete_dims = []
        for i in range(self.dimensionality):
            if self.space_expanded[i].type == 'discrete':
                discrete_dims += [i]
        return discrete_dims
1341196
def get_flat_size(self):
        
        return sum(
            np.prod(v.get_shape().as_list()) for v in self.variables.values())