Decorates the structure with oxidation state, guessing
        using Composition.oxi_state_guesses()

        Args:
            **kwargs: parameters to pass into oxi_state_guesses()
965247
def add_oxidation_state_by_guess(self, **kwargs):
        
        oxid_guess = self.composition.oxi_state_guesses(**kwargs)
        oxid_guess = oxid_guess or \
                     [dict([(e.symbol, 0) for e in self.composition])]
        self.add_oxidation_state_by_element(oxid_guess[0])
1007567
def kwargs(self):
    
    return {k: v for k, v in self._kwargs.items() if k not in self._INTERNAL_FIELDS}
773406
def generate(self, x, **kwargs):
    

    assert self.parse_params(**kwargs)
    labels, _nb_classes = self.get_or_guess_labels(x, kwargs)
    adv_x = self.attack(x, labels)

    return adv_x
1242899
def kwargs(self):
        
        keywords = self.keywords or []
        return [keyword for keyword in keywords if keyword.arg is None]
1280075
def compute_average_oxidation_state(site):
    
    try:
        avg_oxi = sum([sp.oxi_state * occu
                       for sp, occu in site.species.items()
                       if sp is not None])
        return avg_oxi
    except AttributeError:
        pass
    try:
        return site.charge
    except AttributeError:
        raise ValueError("Ewald summation can only be performed on structures "
                         "that are either oxidation state decorated or have "
                         "site charges.")
157343
def hints(self, **kwargs):
        
        new_query = self.query.clone()
        new_query.hints.update(kwargs)

        return self._clone(query=new_query)
152752
def _init_matcher(self, *args, **kwargs):
        

        # If subject-less expectation are provided as arguments convert them
        # to plain Hamcrest matchers in order to allow complex compositions
        fn = lambda x: x.evaluate() if isinstance(x, Expectation) else x
        args = [fn(x) for x in args]
        kwargs = dict((k, fn(v)) for k, v in kwargs.items())

        matcher = self.matcher(*args, **kwargs)
        self.expr.append(matcher)
        self.matcher = None
        return matcher
202950
def self_if_parameters(func):
    
    @wraps(func)
    def wrapper(self, *args, **kwargs):
        result = func(self, *args, **kwargs)
        if args or kwargs:
            return self
        else:
            return result
    return wrapper
160591
def _verify_arguments(self, kwargs):
        
        geom_stat_args = kwargs.keys() | self._stat._kwargs.keys()
        unknown = (geom_stat_args -
                   self.aesthetics() -                # geom aesthetics
                   self.DEFAULT_PARAMS.keys() -        # geom parameters
                   self._stat.aesthetics() -          # stat aesthetics
                   self._stat.DEFAULT_PARAMS.keys() -  # stat parameters
                   {'data', 'mapping',                # layer parameters
                    'show_legend', 'inherit_aes'})    # layer parameters
        if unknown:
            msg = ("Parameters {}, are not understood by "
                   "either the geom, stat or layer.")
            raise PlotnineError(msg.format(unknown))
657981
def find_oxygen_reactions(model):
    """"""
    o2_in_model = helpers.find_met_in_model(model, "MNXM4")
    return set([rxn for met in model.metabolites for
                rxn in met.reactions if met.formula == "O2" or
                met in o2_in_model])
335489
def with_known_args(self, **kwargs):
    """"""
    argspec = inspect.getargspec(self.func)
    stored = {}
    for key, arg in six.iteritems(kwargs):
      if key in argspec.args or argspec.keywords:
        stored[key] = arg
    if stored:
      return self.with_args(**stored)
    return self
100073
def _get_dopants(substitutions, num_dopants, match_oxi_sign):
    
    n_type = [pred for pred in substitutions
              if pred['dopant_species'].oxi_state >
              pred['original_species'].oxi_state
              and (not match_oxi_sign or
                   np.sign(pred['dopant_species'].oxi_state) ==
                   np.sign(pred['original_species'].oxi_state))]
    p_type = [pred for pred in substitutions
              if pred['dopant_species'].oxi_state <
              pred['original_species'].oxi_state
              and (not match_oxi_sign or
                   np.sign(pred['dopant_species'].oxi_state) ==
                   np.sign(pred['original_species'].oxi_state))]

    return {'n_type': n_type[:num_dopants], 'p_type': p_type[:num_dopants]}
1278569
def method_args(self, context, **kwargs):
        
        try:
            _args = self.conf[context].copy()
        except KeyError:
            _args = kwargs
        else:
            _args.update(kwargs)
        return _args
513427
def from_dict(cls, d):
        
        atoms_n_occu = {}
        for sp_occu in d["species"]:
            if "oxidation_state" in sp_occu and Element.is_valid_symbol(
                    sp_occu["element"]):
                sp = Specie.from_dict(sp_occu)
            elif "oxidation_state" in sp_occu:
                sp = DummySpecie.from_dict(sp_occu)
            else:
                sp = Element(sp_occu["element"])
            atoms_n_occu[sp] = sp_occu["occu"]
        props = d.get("properties", None)
        return cls(atoms_n_occu, d["xyz"], properties=props)
797698
def pred_from_comp(self, composition):
        
        output = []
        predictions = self.pred_from_list(composition.elements)
        for p in predictions:
            subs = p['substitutions']
            charge = 0
            for i_el in composition.elements:
                f_el = subs[i_el]
                charge += f_el.oxi_state * composition[i_el]
            if charge == 0:
                output.append(p)
        logging.info('{} charge balanced '
                     'compositions found'.format(len(output)))
        return output
217461
def fill_kwargs(self, input_layer, kwargs):
    """"""
    return input_layer._replace_args_with_defaults(_args=self._assign_defaults,
                                                   **kwargs)
50814
def createArgs(**kwargs):
  
  if len(kwargs) == 0: return [{}]
  kargs = deepcopy(kwargs)
  k1 = kargs.keys()[0]
  values = kargs.pop(k1)
  args = []

  # Get all other combinations
  otherArgs = createArgs(**kargs)

  # Create combinations for values associated with k1
  for v in values:
    newArgs = deepcopy(otherArgs)
    arg = {k1: v}
    for newArg in newArgs:
      newArg.update(arg)
      args.append(newArg)

  return args