Giter VIP home page Giter VIP logo

smop's People

Contributors

alexg31 avatar iglesias avatar johnyf avatar perimosocordiae avatar victorlei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

smop's Issues

Bug: Dot product and element-wise product translation inverted

Matlab operator * is the dot product when multiplying matrices or vectors
and is translated to python operator * which is the element-wise multiplication when
using matrices or vectors; while matlab operator .* which is the element-wise multiplication is translated to .dot()

preserve comments

Comments annotate code as a docstring and at the few places where the code itself does not suffice for readability. For this reason it would be nice to provide an option for converting MATLAB comments to python comments. This was mentioned also in #12 and in this issue on chiselapp.

Bug: np.array affectation is reference affectation

Matlab's operator = deep copies the matrix, while in numpy it's only the reference that is copied, even when affecting a sub part of the matrix/vector.
Fix:
a = b
should be:
a = np.array(b)
when b is a vector/matrix.

But it's not useful when affecting the result of an operation:
a = b * b
for example.

PS: adding spaces right and left of the = operator would make code more readable, as keeping comments and line feeds.

add 'convert' to project description

perhaps adding 'convert' to the project description would increase the probability of google suggesting it for a "convert matlab to python" search

length function

lenght function should be converted to len

currently:

arr{1} = 1;
arr{2} = 2;
lentgh(arr);

converted to

arr[1] = 1
arr[1] = 1
lenght(arr)

Join efforts with other projects

There are several other projects that translate matlab to python. The most relevant seems to be these two, also written in python and BSD / MIT licensed:
https://bitbucket.org/juricap/ompc/src
https://github.com/miaoever/Mat2py

I'm not certain which project is furthest along (I chose this one to bug since it was the most recent), but working on finishing one codebase to perfection rather than having three different but incomplete ones ought to be much more efficient...

round and filter get converted to round_ and filter_

Example:

function a = test(b)
         [c,d] = butter(4, 'low')
         a = filter(c,d, b)
         a = round(a)
end

gets converted to:

def test(b):
    c, d = butter(4, 'low') # nargout=2
    a = filter_(c, d, b)
    a = round_(a)
    return a

This happens both in the master branch and @perimosocordiae's divergent branch.

Any pointers?

Recognize structure fields as array

This Matlab function:

    function a = test(m)
             a = m.member(:, 0)
    end

produces this python function:

    def test(m):
        a = m.member(:, 0)
        return a

The obvious conclusion I can make is that smop is detecting any symbol with '.' in it as a function. Any idea what would need to be changed to fix this?

TBD

  • cython?
  • arrays with [ ], structs
  • command mode
  • comments
  • dot op
  • fastsplver
  • compare performance --> profiler
  • .py3 compatibility
  • pep8
  • ompc examples
  • libermate examples
  • matlab2fortran -> regex.m low prio
  • pypy

function with no argin translated incorrectly

matlab:

function ret = noargin()
    ret = 0

python:

# Autogenerated with SMOP version 0.25
# main.py test.m -o test.py
from __future__ import division
import numpy as np
from runtime import *
def noargin_(,nargout=1):
    #3
    ret=0
    return ret

UNC path is not understood under some rare conditions

For unknown reason, UNC path combined with asterisk, as in smop \foo\bar\bzz*.m is not understood and somehow prevents smop from being run. Other, similar, expressions work just fine. For example, smop "\foo\bar\bzz*.m" (note the quotes) is okay.

fail to run "Working example: solver.m" in README

Hi all,
I am new to Python and need to convert some MATLAB code to Python code, so I tried the "Working example: solver.m" on https://github.com/victorlei/smop/blob/master/README.rst as a start, but got the error message:

~/Downloads/smop-0.25.4/smop> python main.py solver.m
Traceback (most recent call last):
File "main.py", line 164, in
main()
File "main.py", line 157, in main
G = resolve.resolve(func_obj)
File "/nfs/yugong/data/jnwang/Downloads/smop-0.25.4/smop/resolve.py", line 65, in resolve
G = as_networkx(t)
File "/nfs/yugong/data/jnwang/Downloads/smop-0.25.4/smop/resolve.py", line 50, in as_networkx
G.add_node(uu, ident=u) # label=label)
TypeError: add_node() got an unexpected keyword argument 'ident'

I also tried the latest version smop-0.25.6, and ended up with the same error, anyone knows what is the problem? I am using openSUSE 13.1, python 2.7.6, and MATLAB R2012b.

Thanks a lot!

crash in interactive mode

=>> function x=foo(y); x=y; end
Traceback (most recent call last):
File "main.py", line 139, in
main()
File "main.py", line 93, in main
resolve.resolve(t,symtab)
File "/home/lei/smop-github/smop/resolve.py", line 67, in resolve
u = G.node[n]["ident"]
KeyError: 'ident'
lei@dilbert ~/smop-github/smop $

fastsolver.py missing all but the headers

I accidentally uploaded a development version -- sorry I have no experience with git... Meanwhile download version 0.22 -- it is supposed to work . In particular, you should be able to run

python -m fastsolver.py

Without error messages.

what simple and obvious step did I miss?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.