Exemplo n.º 1
0
def maggr(cmd_ctx):
    m = _get_matrix_block(cmd_ctx, cmd_ctx.cmdArgs[0])
    axis = cmd_ctx.cmdArgs[2]
    op = cmd_ctx.cmdArgs[3]
    expr = cmd.unescape_expression(cmd_ctx.cmdArgs[1])
    code = compile("numpy.{0}({1}, axis={2})".format(op, expr, axis), "", "eval")
    tmp = eval(code, {"numpy": numpy, "x": m})
    res = None
    if axis == "None":
        slave = _get_redis_slave(cmd_ctx, const.get_slave_name(cmd_ctx.cmdArgs[4]))
        slave.set(cmd_ctx.cmdArgs[4], tmp)
    else:
        res = numpy.matrix([tmp])
        if axis == "1":
            res = res.T
        _save_matrix_block(cmd_ctx, cmd_ctx.cmdArgs[4], res)
Exemplo n.º 2
0
def _save_matrix_block(cmd_ctx, block_name, data):
    slave = _get_redis_slave(cmd_ctx, const.get_slave_name(block_name))
    slave.set(block_name, data.dumps())
Exemplo n.º 3
0
 def delete_block(self, block_name):
     slave_redis = self.get_slave_redis(const.get_slave_name(block_name))
     slave_redis.delete(block_name)
Exemplo n.º 4
0
 def set_value(self, key, value):
     slave_redis = self.get_slave_redis(const.get_slave_name(key))
     return slave_redis.set(key, value)
Exemplo n.º 5
0
 def get_block(self, block_name):
     slave_redis = self.get_slave_redis(const.get_slave_name(block_name))
     return numpy.loads(slave_redis.get(block_name))
Exemplo n.º 6
0
 def create_block(self, block_name, data):
     slave_redis = self.get_slave_redis(const.get_slave_name(block_name))
     slave_redis.set(block_name, data.dumps())