Beispiel #1
0
def Assign(node):
    return assign.Assign(node)  # Default

    lhs, rhs = node
    print('here')
    # assign a my_var = [a.val], a is a structs, my_var should be a vec
    if node[1].cls == "Matrix" and node[1].backend == "structs":
        element = rhs[0][0]
        if element.backend == "structs":
            size = rhs.str
            var = lhs.name
            name = element.name
            value = element.value

            declares = node.func[0]
            if "_i" not in declares:
                declare = matlab2cpp.collection.Var(declares, "_i")
                declare.type = "sword"
                declare.backend = "sword"
                declares.translate()

            string = var + ".resize(" + size + ") ;\n" +\
                "for (_i=0; _i<" + size + "; ++_i)\n  "+\
                var + "[_i] = " + name + "[_i]." + value + " ;"

            return string

    return "%(0)s = %(1)s"
Beispiel #2
0
    def assignCmd(self, *args):

        targetCtl = cmds.textField(self._uiPointer.txf, q=1, tx=1)

        sels = cmds.ls(sl=1)

        targets = sels[:-1]
        base = sels[-1]

        assign.Assign(targets, base)

        ctlCon.ConnectWidthMainBlendShape(targetCtl, base)
Beispiel #3
0
def Assign(node):

    #left-hand-side, right-hand-side
    lhs, rhs = node

    assert rhs.cls in ("Matrix", "Cell")

    # no content in matrix
    if len(rhs[0]) == 0:
        return "%(0)s.reset() ;"

    # non-numerical values in matrix or variable assign
    if not lhs.num or not rhs.num:
        return "%(0)s = %(1)s ;"

    # new local variable 'ctype' contains convertion type
    node.type = node["ctype"] = node[0].type
    dim = node.dim
    node.dim = 0

    # decomposed matrix
    if rhs.value:

        type = node.type
        if type == "int":
            type = "sword"

        # scalar
        if rhs.dim == 0:
            return arma.scalar_assign(node)

        # colvec
        elif rhs.dim == 1:

            # save number of rows as 'rows'
            node["rows"] = len(node[1][0]) * len(node[1])

            return type + " _" + node[0].name + " [] = %(1)s ;\n"+\
                "%(0)s = %(ctype)s(_" + node[0].name + ", %(rows)s, false) ;"

        # rowvec
        elif rhs.dim == 2:

            # save number of cols as 'cols'
            node["cols"] = len(node[1][0]) * len(node[1])
            return type + " _" + node[0].name + " [] = %(1)s ;\n"+\
                "%(0)s = %(ctype)s(_" + node[0].name + ", %(cols)s, false) ;"

        # matrix
        elif rhs.dim == 3:
            # save number of rows and columns
            node["rows"] = len(node[1][0])
            node["cols"] = len(node[1])
            return type + " _" + node[0].name + " [] = %(1)s ;\n"+\
        "%(0)s = arma::strans(%(ctype)s(_" + node[0].name + ", %(rows)s, %(cols)s, false)) ;"

        assert False

    else:
        node.dim = dim

    return assign.Assign(node)
Beispiel #4
0
if args['improved']:
    giveaway_estimator = estimate.InformedEstimator(args['gates'],
                                                    args['boxcap'], avg, std)
else:
    giveaway_estimator = estimate.Estimator(args['gates'], args['boxcap'], avg,
                                            std)
if args['plot']:
    D = []
    for c in range(0, args['boxcap']):
        D.append(giveaway_estimator.get_giveaway([c]))
    plt.plot(D)
    plt.show()
    exit()

# Run the simulation
assigner = assign.Assign(args['debug'], giveaway_estimator)
sim = simulation.Simulation(args['gates'], args['cars'], args['boxcap'])
sim.reset(assigner.assign, args['time'])
n = 0
for w in weights:
    sim.step(w)
    if (args['debug']):
        print(sim)
    n += 1
    if args['number'] > 0 and n >= args['number']:
        break
for i in range(len(sim.cars)):
    sim.step(0)
    if (args['debug']):
        print(sim)
Beispiel #5
0
import assign
import discord
import join
import respond
import sys

bot = discord.ext.commands.Bot('')

# register Cogs
bot.add_cog(join.Join(bot))
bot.add_cog(assign.Assign(bot))
bot.add_cog(respond.Respond(bot))

bot.run(sys.argv[1])