def gen_even_slices(n, n_packs, n_samples=None):
 start = 0
 if (n_packs < 1):
  raise ValueError(('gen_even_slices got n_packs=%s, must be >=1' % n_packs))
 for pack_num in range(n_packs):
  this_n = (n // n_packs)
  if (pack_num < (n % n_packs)):
   this_n += 1
  if (this_n > 0):
   end = (start + this_n)
   if (n_samples is not None):
    end = min(n_samples, end)
   (yield slice(start, end, None))
   start = end

def gen_even_slices ( n , n_packs , n_samples = None ) : start = 0 if ( n_packs < 1 ) : raise ValueError ( ( 'gen_even_slices got n_packs=%s, must be >=1' % n_packs ) ) for pack_num in range ( n_packs ) : this_n = ( n // n_packs ) if ( pack_num < ( n % n_packs ) ) : this_n += 1 if ( this_n > 0 ) : end = ( start + this_n ) if ( n_samples is not None ) : end = min ( n_samples , end ) ( yield slice ( start , end , None ) ) start = end
generator to create n_packs slices going up to n .