docstr: Set position to nearest bound
  
  This method resets particles that exceed the bounds to the nearest
  available boundary. For every axis on which the coordiantes of the particle
  surpasses the boundary conditions the coordinate is set to the respective
  bound that it surpasses.
  The following equation describes this strategy:
  
  .. math::
  
      x_{i, t, d} = \begin{cases}
                          lb_d & \quad \text{if }x_{i, t, d} < lb_d \\
                          ub_d & \quad \text{if }x_{i, t, d} > ub_d \\
                          x_{i, t, d} & \quad \text{otherwise}
                    \end{cases}
docstr_tok: ["Set","position","to","nearest","bound","This","method","resets","particles","that","exceed","the","bounds","to","the","nearest","available","boundary",".","For","every","axis","on","which","the","coordiantes","of","the","particle","surpasses","the","boundary","conditions","the","coordinate","is","set","to","the","respective","bound","that","it","surpasses",".","The","following","equation","describes","this","strategy",":","..","math",":",":","x_","{","i",",","t",",","d","}","=","\\begin","{","cases","}","lb_d","&","\\quad","\\text","{","if","}","x_","{","i",",","t",",","d","}","<","lb_d","\\\\","ub_d","&","\\quad","\\text","{","if","}","x_","{","i",",","t",",","d","}",">","ub_d","\\\\","x_","{","i",",","t",",","d","}","&","\\quad","\\text","{","otherwise","}","\\end","{","cases","}"]
code: def nearest(self, position, bounds, **kwargs):
      r"""Set position to nearest bound
  
          This method resets particles that exceed the bounds to the nearest
          available boundary. For every axis on which the coordiantes of the particle
          surpasses the boundary conditions the coordinate is set to the respective
          bound that it surpasses.
          The following equation describes this strategy:
  
          .. math::
  
              x_{i, t, d} = \begin{cases}
                                  lb_d & \quad \text{if }x_{i, t, d} < lb_d \\
                                  ub_d & \quad \text{if }x_{i, t, d} > ub_d \\
                                  x_{i, t, d} & \quad \text{otherwise}
                            \end{cases}
  
          """
      lb, ub = bounds
      bool_greater = position > ub
      bool_lower = position < lb
      new_pos = np.where(bool_lower, lb, position)
      new_pos = np.where(bool_greater, ub, new_pos)
      return new_pos
  
imports: import inspect
  import logging
  import numpy
  import math
  from copy import copy
  from ..utils.reporter import Reporter
label_desc: Use image node_id 3 for calling the BoundaryHandler obj's underlying member method code with example usage: obj.nearest(position, bounds) and returns: new_pos