docstr: Reflect the particle at the boundary
  
  This method reflects the particles that exceed the bounds at the
  respective boundary. This means that the amount that the component
  which is orthogonal to the exceeds the boundary is mirrored at the
  boundary. The reflection is repeated until the position of the particle
  is within the boundaries. The following algorithm describes the
  behaviour of this strategy:
  
  .. math::
      :nowrap:
  
      \begin{gather*}
          \text{while } x_{i, t, d} \not\in \left[lb_d,\,ub_d\right] \\
          \text{ do the following:}\\
          \\
          x_{i, t, d} =   \begin{cases}
                              2\cdot lb_d - x_{i, t, d} & \quad \text{if } x_{i,
                              t, d} < lb_d \\
                              2\cdot ub_d - x_{i, t, d} & \quad \text{if } x_{i,
                              t, d} > ub_d \\
                              x_{i, t, d} & \quad \text{otherwise}
                          \end{cases}
      \end{gather*}
docstr_tok: ["Reflect","the","particle","at","the","boundary","This","method","reflects","the","particles","that","exceed","the","bounds","at","the","respective","boundary",".","This","means","that","the","amount","that","the","component","which","is","orthogonal","to","the","exceeds","the","boundary","is","mirrored","at","the","boundary",".","The","reflection","is","repeated","until","the","position","of","the","particle","is","within","the","boundaries",".","The","following","algorithm","describes","the","behaviour","of","this","strategy",":","..","math",":",":",":","nowrap",":","\\begin","{","gather","*","}","\\text","{","while","}","x_","{","i",",","t",",","d","}","\\not\\in","\\left","[","lb_d",",","\\",",","ub_d\\right","]","\\\\","\\text","{","do","the","following",":","}","\\\\","\\\\","x_","{","i",",","t",",","d","}","=","\\begin","{","cases","}","2\\cdot","lb_d","-","x_","{","i",",","t",",","d","}","&","\\quad","\\text","{","if","}","x_","{","i",",","t",",","d","}","<","lb_d","\\\\","2\\cdot","ub_d","-","x_","{","i",",","t",",","d","}","&","\\quad","\\text","{","if","}","x_","{","i",",","t",",","d","}",">","ub_d","\\\\","x_","{","i",",","t",",","d","}","&","\\quad","\\text","{","otherwise","}","\\end","{","cases","}","\\end","{","gather","*","}"]
code: def reflective(self, position, bounds, **kwargs):
      r"""Reflect the particle at the boundary
  
          This method reflects the particles that exceed the bounds at the
          respective boundary. This means that the amount that the component
          which is orthogonal to the exceeds the boundary is mirrored at the
          boundary. The reflection is repeated until the position of the particle
          is within the boundaries. The following algorithm describes the
          behaviour of this strategy:
  
          .. math::
              :nowrap:
  
              \begin{gather*}
                  \text{while } x_{i, t, d} \not\in \left[lb_d,\,ub_d\right] \\
                  \text{ do the following:}\\
                  \\
                  x_{i, t, d} =   \begin{cases}
                                      2\cdot lb_d - x_{i, t, d} & \quad \text{if } x_{i,
                                      t, d} < lb_d \\
                                      2\cdot ub_d - x_{i, t, d} & \quad \text{if } x_{i,
                                      t, d} > ub_d \\
                                      x_{i, t, d} & \quad \text{otherwise}
                                  \end{cases}
              \end{gather*}
          """
      lb, ub = bounds
      lower_than_bound, greater_than_bound = self._out_of_bounds(
          position, bounds
      )
      new_pos = position
      while (
          lower_than_bound[0].size != 0
          or greater_than_bound[0].size != 0
      ):
          if lower_than_bound[0].size > 0:
              new_pos[lower_than_bound] = (
                  2 * lb[lower_than_bound[1]]
                  - new_pos[lower_than_bound]
              )
          if greater_than_bound[0].size > 0:
              new_pos[greater_than_bound] = (
                  2 * ub[greater_than_bound[1]]
                  - new_pos[greater_than_bound]
              )
          lower_than_bound, greater_than_bound = self._out_of_bounds(
              new_pos, bounds
          )
  
      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 4 for calling the BoundaryHandler obj's underlying member method code with example usage: obj.reflective(position, bounds) and returns: new_pos