#!/usr/bin/env python
# coding:utf-8
# vi:tabstop=4:shiftwidth=4:expandtab:sts=4

import numpy as np
import random
import theano

class LocalShuffler(object):
    def __init__(self,size,shape):
        self.xpool=np.zeros((size,)+shape,dtype=theano.config.floatX)
        self.ypool=[0]*size
        self.size=size
        self.fill=0
    def feed(self,data,y):
        if data is None:
            if self.fill>0:
                n = self.fill-1
                self.fill-=1
                return self.xpool[n],self.ypool[n]
            else:
                return None
        if self.fill==self.size:
            n = int(random.random()*self.size)
            res = (self.xpool[n],self.ypool[n])
            self.xpool[n]=data
            self.ypool[n]=y
            return res
        else:
            n = self.fill
            self.xpool[n]=data
            self.ypool[n]=y
            self.fill+=1
            return None
    def is_empty(self):
        return self.fill==0
    def is_full(self):
        assert self.fill<=self.size
        return self.fill==self.size

@@ -281,24 +281,53 @@
 ol=%5B0%5D*size%0A
+        self.idpool=%5B0%5D*size%0A
         self
@@ -381,16 +381,19 @@
 f,data,y
+,id
 ):%0A     
@@ -551,16 +551,31 @@
 ypool%5Bn%5D
+,self.idpool%5Bn%5D
 %0A       
@@ -739,16 +739,31 @@
 ypool%5Bn%5D
+,self.idpool%5Bn%5D
 )%0A      
@@ -807,32 +807,62 @@
 self.ypool%5Bn%5D=y%0A
+            self.idpool%5Bn%5D=id%0A
             retu
@@ -959,32 +959,62 @@
 self.ypool%5Bn%5D=y%0A
+            self.idpool%5Bn%5D=id%0A
             self

support id