code: def _set_BC(self, pores, bctype, bcvalues=None, mode='merge'):
          r
          # Hijack the parse_mode function to verify bctype argument
          bctype = self._parse_mode(bctype, allowed=['value', 'rate'],
                                    single=True)
          mode = self._parse_mode(mode, allowed=['merge', 'overwrite', 'remove'],
                                  single=True)
          pores = self._parse_indices(pores)
  
          values = np.array(bcvalues)
          if values.size > 1 and values.size != pores.size:
              raise Exception('The number of boundary values must match the ' +
                              'number of locations')
  
          # Store boundary values
          if ('pore.bc_'+bctype not in self.keys()) or (mode == 'overwrite'):
              self['pore.bc_'+bctype] = np.nan
          self['pore.bc_'+bctype][pores] = values
docs: r"""
          Apply boundary conditions to specified pores
  
          Parameters
          ----------
          pores : array_like
              The pores where the boundary conditions should be applied
  
          bctype : string
              Specifies the type or the name of boundary condition to apply. The
              types can be one one of the following:
  
              - *'value'* : Specify the value of the quantity in each location
              - *'rate'* : Specify the flow rate into each location
  
          bcvalues : int or array_like
              The boundary value to apply, such as concentration or rate.  If
              a single value is given, it's assumed to apply to all locations.
              Different values can be applied to all pores in the form of an
              array of the same length as ``pores``.
  
          mode : string, optional
              Controls how the conditions are applied.  Options are:
  
              *'merge'*: (Default) Adds supplied boundary conditions to already
              existing conditions.
  
              *'overwrite'*: Deletes all boundary condition on object then add
              the given ones
  
          Notes
          -----
          It is not possible to have multiple boundary conditions for a
          specified location in one algorithm. Use ``remove_BCs`` to
          clear existing BCs before applying new ones or ``mode='overwrite'``
          which removes all existing BC's before applying the new ones.