Skip to content

Octave support#75

Merged
arokem merged 8 commits intoarokem:masterfrom
isbadawi:octave
Aug 5, 2014
Merged

Octave support#75
arokem merged 8 commits intoarokem:masterfrom
isbadawi:octave

Conversation

@isbadawi
Copy link
Collaborator

This is a followup to #74. I don't expect this to be merged yet, but I'd like to get feedback on a few things.

I got this mostly working with Octave. I did a few things:

  • I removed the json package being used and replaced it with jsonlab. It's pure MATLAB -- I'm not sure what the performance implications of this are. I've also run into weird issues around special characters. The interface at least is similar; loadjson instead of json.load, and savejson instead of json.dump. With the issues I ran into I'm not sure about how good this library is -- an alternative might be to make changes to the original json package to be compatible with Octave (remove the +pkg style, and rewrite the code that interacts with the java classes). Anyway, this is the first commit.
  • I made changes to pymatbridge.py to handle the different command line interfaces for Matlab and Octave. I extracted most of the Matlab class into a base Session class, with Matlab and Octave as subclasses. Along the way I eliminated some small bits of code duplication. This is the second commit.
  • Not included in this PR, I also had to recompile the messenger to work with Octave, using mkoctfile --mex. (No C code changes required). I'm not sure how to integrate this with the build system and prebuilt binaries you have here.

Finally, there didn't seem to be a way to disable showing plots in Octave, like -nodisplay does for Matlab, short of running figure('visible', 'off') before every command. I'm not sure what to do about this.

Let me know what you think of this so far.

@arokem
Copy link
Owner

arokem commented Jul 28, 2014

Thanks for working on this! I just wanted to let you know that I will look
at it, but it might take me a few days before I get to it.

On Mon, Jul 28, 2014 at 1:42 PM, Ismail Badawi notifications@github.com
wrote:

This is a followup to #74
#74. I don't
expect this to be merged yet, but I'd like to get feedback on a few things.

I got this mostly working with Octave. I did a few things:

  • I removed the json package being used and replaced it with jsonlab
    http://iso2mesh.sourceforge.net/cgi-bin/index.cgi?jsonlab. It's pure
    MATLAB -- I'm not sure what the performance implications of this are. I've
    also run into weird issues around special characters
    https://groups.google.com/forum/?hl=en#!topic/iso2mesh-users/fySUOU5wKyc.
    The interface at least is similar; loadjson instead of json.load, and
    savejson instead of json.dump. With the issues I ran into I'm not sure
    about how good this library is -- an alternative might be to make changes
    to the original json package to be compatible with Octave (remove the +pkg
    style, and rewrite the code that interacts with the java classes). Anyway,
    this is the first commit.
  • I made changes to pymatbridge.py to handle the different command
    line interfaces for Matlab and Octave. I extracted most of the Matlab
    class into a base Session class, with Matlab and Octave as subclasses.
    Along the way I eliminated some small bits of code duplication. This is the
    second commit.
  • Not included in this PR, I also had to recompile the messenger to
    work with Octave, using mkoctfile --mex. (No C code changes required).
    I'm not sure how to integrate this with the build system and prebuilt
    binaries you have here.

Finally, there didn't seem to be a way to disable showing plots in Octave,
like -nodisplay does for Matlab, short of running figure('visible', 'off')
before every command. I'm not sure what to do about this.

Let me know what you think of this so far.

You can merge this Pull Request by running

git pull https://github.com/isbadawi/python-matlab-bridge octave

Or view, comment on, or merge it at:

#75
Commit Summary

  • Replace json package with jsonlab.
  • Add support for invoking Octave instead of Matlab.

File Changes

Patch Links:


Reply to this email directly or view it on GitHub
#75.

@isbadawi
Copy link
Collaborator Author

Okay, thanks!

I ran into still more issues with jsonlab, including a couple of tests that I couldn't get to pass. I gave up on it and just modified the existing json package. It was way less work than I thought it would be (see the first two commits), and everything seems to work well. I should have just done that from the beginning.

I rebased and git push -fd, so you can ignore everything I said about jsonlab when reviewing this.

isbadawi added 3 commits July 30, 2014 13:28
* Extract most of the Matlab class into a base Session class
* Matlab and Octave are subclasses that tweak the command line
  invocation
* Eliminate some code duplication along the way
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove the time-out?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The maxtime parameter wasn't actually being used in run_func, run_code or get_variable, so I removed it and then fixed the call sites. I guess we could implement a timeout in those methods, but even then it might make more sense to just use self.maxtime rather than a parameter.

@arokem
Copy link
Owner

arokem commented Aug 3, 2014

Looks good - tests are all passing on my setup. Would you mind writing some tests for Octave? I don't have it currently installed, but will install and try those out, if you write them. Other than that, I only had a couple of comments. Let me know when you want me to take another look, and merge this in.

@isbadawi
Copy link
Collaborator Author

isbadawi commented Aug 3, 2014

Okay, sure. Rather than writing new tests, I made it so that the existing tests will run under Octave if you set the USE_OCTAVE environment variable; this way you can still run the tests if you only have one of the two installed. This mostly works except that the tests in TestRunCode rely on MATLAB output which is different in Octave, so I added checks in those to have different asserts if the tests are running in Octave mode. The matlab magic tests still use Matlab. What do you think of this approach?

Finally, in order to run the tests you need to compile the messenger for Octave, as I mentioned initially. I can do this with an invocation like mkoctfile --mex -lzmq messenger.c (I just had to make a couple of tiny changes to the C code), but I'm not sure where that should go in the make.py scheme.

@arokem
Copy link
Owner

arokem commented Aug 5, 2014

Great. Maybe just add a bit to the README file to describe these differences, and tell people what to do under Octave? Apart from that, I think this is ready to be merged. Thanks a lot for making this pull request!

@isbadawi
Copy link
Collaborator Author

isbadawi commented Aug 5, 2014

Okay, I added a bit to the README. I just realized that renaming the matlab parameter to the Matlab constructor to executable is backwards incompatible (I noticed because the README mentions specifying the path to matlab by passing matlab='...'). Do you think this matters?

@arokem
Copy link
Owner

arokem commented Aug 5, 2014

I think that's OK - it's a relatively small change, which would be easy for people to fix up in their code. I will merge this, and we can see if we start getting a lot of complaints about this changed...

arokem added a commit that referenced this pull request Aug 5, 2014
@arokem arokem merged commit a5fbc5e into arokem:master Aug 5, 2014
@isbadawi isbadawi mentioned this pull request Aug 5, 2014
@isbadawi isbadawi deleted the octave branch August 5, 2014 17:40
isbadawi added a commit to Sable/mclab-ide that referenced this pull request Aug 5, 2014
A new "backend" setting can be set to either "MATLAB" or "Octave";
this affects both the shell and the call graph instrumentation.

This depends on arokem/python-matlab-bridge#75.

A sort-of-unrelated change in this commit is that the Matlab or
Octave session is initialized asynchronously after the page has
loaded, instead of making the page hang.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants