code: def unitcheck(u, nonperiodic=None):
      
  
      if nonperiodic is None:
          # No periodic boundary conditions provided.
          return np.all(u > 0.) and np.all(u < 1.)
      else:
          # Alternating periodic and non-periodic boundary conditions.
          return (np.all(u[nonperiodic] > 0.) and
                  np.all(u[nonperiodic] < 1.) and
                  np.all(u[~nonperiodic] > -0.5) and
                  np.all(u[~nonperiodic] < 1.5))
docs: Check whether `u` is inside the unit cube. Given a masked array
      `nonperiodic`, also allows periodic boundaries conditions to exceed
      the unit cube.