예제 #1
0
    input_expr = str(list(range(40, 60)))

    def __init__(self):
        pass

    def computed_input(self):
        try:
            res = eval(self.input_expr)
            if type(res) is list: return res
            return []
        except:
            return []

    def computed_taginput(self):
        return ['%s#%03d' % (str(v), i) for i, v in enumerate(self.input)]

    def computed_tagoutput(self):
        try:
            locals()[self.i_name] = self.input
            locals()['___' + self.i_name] = self.taginput
            res = eval('___%s[%s]' % (self.i_name, self.slice_expr))
            self.is_error = False
            return res
        except Exception as e:
            self.is_error = True
            self.error_message = str(e)
            return []


start(Comp())
예제 #2
0
@vuejspython.model
class App:

    # input = np.random.uniform(-1000, 1000, 10)
    input = 4 + 5 * np.sin(np.linspace(-6, 5, 15))
    scale = 1
    bias = 0

    def computed_size(self):
        return len(self.input)

    def computed_scaled(self):
        return np.array(self.input) * self.scale

    def computed_biased(self):
        return np.array(self.scaled) - self.bias

    def computed_relu(self):
        res = np.copy(self.biased)
        #res[res < self.bias] = self.bias
        res[res < 0] = 0
        return res

    def computed_logsoftmax(self):
        smax = np.exp(self.relu)
        smax /= np.sum(smax)
        return np.log(smax + 0.000001)


vuejspython.start(App())
예제 #3
0
        self.i2_withwatch = i * i

    def computed_i2(self):
        print("TEST: COMPUTING i2")
        return self.i**2

    async def demo_incr(self, t, v):
        while True:
            await asyncio.sleep(t)
            self.i += v

    def meth1(self, v):
        print("TEST: COMMAND", v)
        self.subtitle = "Changed: " + v  # will not trigger change as _novue
        if v == '+1':
            self.i += 1

    async def meth2(self, v):
        await asyncio.sleep(1)
        return str(v[::-1])

    def meth3(self, v):
        return str(v[::-1])

    def clone(self, v):
        print("TEST: CLONE", type(self.suggestions))
        self.suggestions += [v]


vuejspython.start(Comp())
예제 #4
0
        cla = wa.sum(axis=1)  # ts, cl
        clp = np.exp(cla) / np.sum(np.exp(cla), axis=1,
                                   keepdims=True)  # ts, cl

        def diffp(sh):
            no_cla = wa[:, np.arange(n_sh) != sh, :].sum(axis=1)
            no_cla = np.exp(no_cla)
            no_clp = no_cla / np.sum(no_cla, axis=1, keepdims=True)
            #d = clp[:, :] - no_clp[:, :]
            d = clp[:, cc] - no_clp[:, cc]
            #d[d<0.2] = 0
            d[d < 0.01] = 0
            return np.mean(d)

        #self.importance3 = [diffp(sh) * 100000 for sh in range(n_sh)]
        imp3 = np.array([diffp(sh) for sh in range(n_sh)])
        imp3 *= 200 / np.max(imp3)
        return imp3

    def watch_currentShapelet(self, cs):
        # up current image
        g = 0
        while cs >= self.groups[g]:
            cs -= self.groups[g]
            g += 1
        self.currentImage = f'{self.folder}/plot/group{g}_shapelet{cs}.png'


m = Comp()
vuejspython.start(Comp(), py_port=4242)
예제 #5
0
파일: histo.py 프로젝트: twitwi/trail-tools
    def do_compute_image(self, level, vx, vy, vw, vh):
        scale = 2**level
        x = vx//scale
        y = vy//scale
        w = vw//scale
        h = vh//scale
        arr = getattr(self, 'l'+str(level))[y:y+h,x:x+w]
        arr = arr[::-1, :]
        arr /= arr.tocsr().max()
        res = [(int(u), int(v), int(arr[u,v]*100)) for (i,(u,v)) in enumerate(zip(*(arr.nonzero())))] # sparse: list of (i,j,v)
        return res

    def computed_image0(self):
        return self.do_compute_image(0, self.view_x, self.view_y, self.view_w, self.view_h)

    def computed_image1(self):
        return self.do_compute_image(1, self.view_x, self.view_y, self.view_w, self.view_h)

    def computed_image2(self):
        return self.do_compute_image(2, self.view_x, self.view_y, self.view_w, self.view_h)

    @vuejspython.atomic # BUG
    def offset_view(self, dx, dy):
        self.view_x += int(dx)
        self.view_y += int(dy)

vuejspython.start(App(), py_port=42989)


예제 #6
0
파일: main.py 프로젝트: twitwi/auto-grade
    def computed_project_full_path(self):
        if self.project_path.startswith('/'):
            return self.project_path
        p = self.local_MC
        if p[-1] != '/':
            p += '/'
        return p + self.project_path

    def __init__(self, argv):
        if len(argv) > 1:
            self.project_path = argv[1]
            if self.project_path.startswith(self.local_MC):
                self.project_path = self.project_path[len(self.local_MC):]

    def log(self, type, msg):
        self.debug_logs.append((type, msg))

    def save_miniset(self, l):
        dir = 'miniset-' + datetime.strftime(datetime.now(), '%Y-%m-%d_%H:%M')
        os.mkdir(dir)
        for c, impath in l:
            cdir = dir + '/class-' + c
            if not os.path.exists(cdir):
                os.mkdir(cdir)
            shutil.copy2(impath, cdir)


import sys
start(AMCParasite(sys.argv), http_host="0.0.0.0", py_host="0.0.0.0")