Ejemplo n.º 1
0
 def __setstate__(self, state):
     "Experimental unpickling support."
     global mlab         #XXX this should be dealt with correctly
     old_name = state['name']
     mlab_name = "UNPICKLED%s__" % gensym('')
     try:
         tmp_filename = mktemp('.mat')
         spitOut(state['mlab_contents'], tmp_filename, binary=1)
         mlab._raw_eval(
           "TMP_UNPICKLE_STRUCT__ = load('%s', '%s');" % (
             tmp_filename, old_name))
         mlab._raw_eval(
           "%s = TMP_UNPICKLE_STRUCT__.%s;" % (mlab_name, old_name))
         mlab._raw_eval("clear TMP_UNPICKLE_STRUCT__;")
         # XXX
         mlab._make_proxy(mlab_name, constructor=lambda *args: self.__init__(*args) or self)
         mlab._raw_eval('clear %s;' % mlab_name)
     finally:
         if os.path.exists(tmp_filename): os.remove(tmp_filename)
Ejemplo n.º 2
0
eq
ne
lt
gt
le
ge

horzcat
vertcat
'''.split()
UNARY_ARITH = '''
uminus
uplus
transpose
ctranspose

'''.split()  # XXX: size needs to be handcoded

for op in BINARY_ARITH:
    spitOut(file=op + ".m",
            s='''function res=%(op)s(X,Y)
res=%(op)s(X.data, Y.data);
end
            ''' % dict(op=op))
for op in UNARY_ARITH:
    spitOut(file=op + ".m",
            s='''function res=%(op)s(X)
res=%(op)s(X.data);
end
''' % dict(op=op))
Ejemplo n.º 3
0
eq
ne
lt
gt
le
ge

horzcat
vertcat
'''.split()
UNARY_ARITH='''
uminus
uplus
transpose
ctranspose

'''.split() # XXX: size needs to be handcoded

for op in BINARY_ARITH:
    spitOut(file=op + ".m", s=
            '''function res=%(op)s(X,Y)
res=%(op)s(X.data, Y.data);
end
            ''' % dict(op=op))
for op in UNARY_ARITH:
    spitOut(file=op + ".m", s=
            '''function res=%(op)s(X)
res=%(op)s(X.data);
end
'''% dict(op=op))