def bag_range(n, npartitions):
 size = (n // npartitions)
 name = ('range-%d-npartitions-%d' % (n, npartitions))
 ijs = list(enumerate(take(npartitions, range(0, n, size))))
 dsk = dict((((name, i), (reify, (range, j, min((j + size), n)))) for (i, j) in ijs))
 if ((n % npartitions) != 0):
  (i, j) = ijs[(-1)]
  dsk[(name, i)] = (reify, (range, j, n))
 return Bag(dsk, name, npartitions)

def bag_range ( n , npartitions ) : size = ( n // npartitions ) name = ( 'range-%d-npartitions-%d' % ( n , npartitions ) ) ijs = list ( enumerate ( take ( npartitions , range ( 0 , n , size ) ) ) ) dsk = dict ( ( ( ( name , i ) , ( reify , ( range , j , min ( ( j + size ) , n ) ) ) ) for ( i , j ) in ijs ) ) if ( ( n % npartitions ) != 0 ) : ( i , j ) = ijs [ ( - 1 ) ] dsk [ ( name , i ) ] = ( reify , ( range , j , n ) ) return Bag ( dsk , name , npartitions )
numbers from zero to n examples .