nodes: 0, module; 1, function_definition; 2, function_name:remove_dataset; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, dictionary_splat_pattern; 8, expression_statement; 9, expression_statement; 10, comment:# Let's avoid deleting ALL parameters from the matching contexts; 11, if_statement; 12, comment:# let's handle deps if kind was passed; 13, expression_statement; 14, if_statement; 15, expression_statement; 16, if_statement; 17, expression_statement; 18, comment:# Let's avoid the possibility of deleting a single parameter; 19, expression_statement; 20, comment:# Let's also avoid the possibility of accidentally deleting system; 21, comment:# parameters, etc; 22, expression_statement; 23, comment:# ps = self.filter(**kwargs); 24, comment:# logger.info('removing {} parameters (this is not undoable)'.\; 25, comment:#             format(len(ps))); 26, comment:# print "*** kwargs", kwargs, len(ps); 27, expression_statement; 28, comment:# not really sure why we need to call this twice, but it seems to do; 29, comment:# the trick; 30, expression_statement; 31, expression_statement; 32, comment:# TODO: check to make sure that trying to undo this; 33, comment:# will raise an error saying this is not undo-able; 34, expression_statement; 35, return_statement; 36, identifier:dataset; 37, None; 38, identifier:kwargs; 39, comment:""" Remove a dataset from the Bundle.
  
          This removes all matching Parameters from the dataset, model, and
          constraint contexts (by default if the context tag is not provided).
  
          You must provide some sort of filter or this will raise an Error (so
          that all Parameters are not accidentally removed).
  
          :parameter str dataset: name of the dataset
          :parameter **kwargs: any other tags to do the filter (except qualifier
              and dataset)
          :raises ValueError: if no filter is provided
          """; 40, call; 41, boolean_operator; 42, block; 43, assignment; 44, comparison_operator:kind is not None; 45, block; 46, assignment; 47, comparison_operator:dataset is None; 48, comment:# then let's find the list of datasets that match the filter,; 49, comment:# we'll then use dataset to do the removing.  This avoids leaving; 50, comment:# pararameters behind that don't specifically match the filter; 51, comment:# (ie if kind is passed as 'rv' we still want to remove parameters; 52, comment:# with datasets that are RVs but belong to a different kind in; 53, comment:# another context like compute); 54, block; 55, assignment; 56, assignment; 57, call; 58, call; 59, call; 60, call; 61, call; 62, attribute; 63, argument_list; 64, comparison_operator:dataset is None; 65, not_operator; 66, raise_statement; 67, identifier:kind; 68, call; 69, identifier:kind; 70, None; 71, if_statement; 72, expression_statement; 73, for_statement; 74, expression_statement; 75, subscript; 76, identifier:kind; 77, identifier:dataset; 78, None; 79, expression_statement; 80, expression_statement; 81, subscript; 82, identifier:dataset; 83, subscript; 84, None; 85, attribute; 86, argument_list; 87, attribute; 88, argument_list; 89, attribute; 90, argument_list; 91, attribute; 92, argument_list; 93, attribute; 94, argument_list; 95, identifier:self; 96, identifier:_kwargs_checks; 97, identifier:kwargs; 98, identifier:dataset; 99, None; 100, call; 101, call; 102, attribute; 103, argument_list; 104, call; 105, block; 106, assignment; 107, identifier:kind_i; 108, identifier:kind; 109, block; 110, assignment; 111, identifier:kwargs; 112, string; 113, assignment; 114, assignment; 115, identifier:kwargs; 116, string; 117, identifier:kwargs; 118, string; 119, identifier:kwargs; 120, identifier:setdefault; 121, string; 122, list; 123, identifier:self; 124, identifier:remove_parameters_all; 125, dictionary_splat; 126, identifier:self; 127, identifier:remove_parameters_all; 128, dictionary_splat; 129, identifier:self; 130, identifier:_handle_dataset_selectparams; 131, identifier:self; 132, identifier:_add_history; 133, keyword_argument; 134, keyword_argument; 135, keyword_argument; 136, keyword_argument; 137, identifier:len; 138, argument_list; 139, identifier:ValueError; 140, argument_list; 141, identifier:kwargs; 142, identifier:get; 143, string; 144, None; 145, identifier:isinstance; 146, argument_list; 147, expression_statement; 148, identifier:kind_deps; 149, list; 150, expression_statement; 151, if_statement; 152, identifier:kind; 153, binary_operator:kind + kind_deps; 154, string_content:kind; 155, identifier:dataset; 156, attribute; 157, subscript; 158, None; 159, string_content:dataset; 160, string_content:qualifier; 161, string_content:context; 162, string; 163, string; 164, string; 165, string; 166, identifier:kwargs; 167, identifier:kwargs; 168, identifier:redo_func; 169, string; 170, identifier:redo_kwargs; 171, dictionary; 172, identifier:undo_func; 173, None; 174, identifier:undo_kwargs; 175, dictionary; 176, call; 177, string:"must provide some value to filter for datasets"; 178, string_content:kind; 179, identifier:kind; 180, identifier:str; 181, assignment; 182, assignment; 183, comparison_operator:dep not in kind; 184, block; 185, identifier:kind; 186, identifier:kind_deps; 187, call; 188, identifier:datasets; 189, identifier:kwargs; 190, string; 191, string_content:dataset; 192, string_content:model; 193, string_content:constraint; 194, string_content:compute; 195, string_content:remove_dataset; 196, pair; 197, attribute; 198, argument_list; 199, identifier:kind; 200, list; 201, identifier:dep; 202, call; 203, identifier:dep; 204, identifier:kind; 205, expression_statement; 206, attribute; 207, argument_list; 208, string_content:kind; 209, string; 210, identifier:dataset; 211, identifier:kwargs; 212, identifier:items; 213, identifier:kind; 214, attribute; 215, argument_list; 216, call; 217, identifier:self; 218, identifier:filter; 219, dictionary_splat; 220, string_content:dataset; 221, string; 222, identifier:format; 223, identifier:kind_i; 224, attribute; 225, argument_list; 226, identifier:kwargs; 227, string_content:{}_dep; 228, identifier:kind_deps; 229, identifier:append; 230, identifier:dep
code: def remove_dataset(self, dataset=None, **kwargs):
          """ Remove a dataset from the Bundle.
  
          This removes all matching Parameters from the dataset, model, and
          constraint contexts (by default if the context tag is not provided).
  
          You must provide some sort of filter or this will raise an Error (so
          that all Parameters are not accidentally removed).
  
          :parameter str dataset: name of the dataset
          :parameter **kwargs: any other tags to do the filter (except qualifier
              and dataset)
          :raises ValueError: if no filter is provided
          """
  
          self._kwargs_checks(kwargs)
  
          # Let's avoid deleting ALL parameters from the matching contexts
          if dataset is None and not len(kwargs.items()):
              raise ValueError("must provide some value to filter for datasets")
  
          # let's handle deps if kind was passed
          kind = kwargs.get('kind', None)
  
          if kind is not None:
              if isinstance(kind, str):
                  kind = [kind]
              kind_deps = []
              for kind_i in kind:
                  dep = '{}_dep'.format(kind_i)
                  if dep not in kind:
                      kind_deps.append(dep)
              kind = kind + kind_deps
          kwargs['kind'] = kind
  
  
          if dataset is None:
              # then let's find the list of datasets that match the filter,
              # we'll then use dataset to do the removing.  This avoids leaving
              # pararameters behind that don't specifically match the filter
              # (ie if kind is passed as 'rv' we still want to remove parameters
              # with datasets that are RVs but belong to a different kind in
              # another context like compute)
              dataset = self.filter(**kwargs).datasets
              kwargs['kind'] = None
  
  
          kwargs['dataset'] = dataset
          # Let's avoid the possibility of deleting a single parameter
          kwargs['qualifier'] = None
          # Let's also avoid the possibility of accidentally deleting system
          # parameters, etc
          kwargs.setdefault('context', ['dataset', 'model', 'constraint', 'compute'])
  
          # ps = self.filter(**kwargs)
          # logger.info('removing {} parameters (this is not undoable)'.\
          #             format(len(ps)))
  
          # print "*** kwargs", kwargs, len(ps)
          self.remove_parameters_all(**kwargs)
          # not really sure why we need to call this twice, but it seems to do
          # the trick
          self.remove_parameters_all(**kwargs)
  
          self._handle_dataset_selectparams()
  
          # TODO: check to make sure that trying to undo this
          # will raise an error saying this is not undo-able
          self._add_history(redo_func='remove_dataset',
                            redo_kwargs={'dataset': dataset},
                            undo_func=None,
                            undo_kwargs={})
  
          return