-
Notifications
You must be signed in to change notification settings - Fork 96
Pythonic API #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pythonic API #63
Conversation
messenger('respond', 'unrecognized command'); | ||
end | ||
|
||
catch exception |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah - good call on that
Wow. This is very cool! I am playing around with this, and it's quite slick. There are still a few things that I wonder about, but generally this is awesome and I think that many people will enjoy using this. Bottom line - I would be happy to integrate this, if you want to work in this direction. It's definitely not in any kind of conflict with anything we are doing. Thanks a lot for your work on this! |
BTW - what is supposed to happen when you call:
or somesuch? I just get back the plot handle, but no plot appears. I imagine that I could save the plot to file using the handle, though I haven't tried that yet. |
the desire would be to show the plot and return the handle, as per Matlab. I'll have to check on that. (obviously you'd have to be running a graphical session) |
I'll send you my latest changes this evening which should hopefully solidify things a bit more. Is there anything in particular you want me to work/focus on? |
Great. Not sure about direction to focus on - I'll play around with this a On Mon, Apr 7, 2014 at 7:14 PM, Hilton Bristow notifications@github.comwrote:
|
Do you have a Json extension to serialize numpy arrays? |
No - maybe we can somehow use the zmq messenger and the pyzmq API and See: We can probably assume that a numpy array on the python side is a matrix on On Mon, Apr 7, 2014 at 7:22 PM, Hilton Bristow notifications@github.comwrote:
|
return resp['result'] | ||
|
||
@property | ||
def __doc__(self, parent): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work for you? I keep getting
TypeError: __doc__() takes exactly 2 arguments (1 given)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must have broken it when I changed to using weakrefs. Will put it on my TODO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which reminds me: don't forget to write some tests for this API. Just to be
sure that things are solid moving forward. If you need help with that, let
me know.
On Mon, Apr 7, 2014 at 7:30 PM, Hilton Bristow notifications@github.comwrote:
In pymatbridge/pymatbridge.py:
}
if nout:
req['nout'] = nout
resp = parent()._execute(req)
if not resp['success']:
if resp['result'] == 'MATLAB:UndefinedFunction':
parent().blacklist.add(self.name)
delattr(parent(), self.name)
raise AttributeError(attribute_msg.format(self.name))
raise RuntimeError(resp['result'] +': '+ resp['message'])
else:
self.**name** = self.name + ' (verified)'
return resp['result']
- @Property
- def doc(self, parent):
Must have broken it when I changed to using weakrefs. Will put it on my
TODO—
Reply to this email directly or view it on GitHubhttps://github.com//pull/63/files#r11374470
.
OK - I am looking at this a bit more, and ran the test suite. Does the added functionality really have to break the previous functionality? |
Sorry - didn't mean to close it. Hit the wrong button... |
Hey, no it doesn't need to break the old API. We can discuss deprecation techniques. I just haven't focussed on that yet. |
Is there a particular reason you're using |
Cool - got it. On Mon, Apr 7, 2014 at 8:46 PM, Hilton Bristow notifications@github.comwrote:
|
No particular reason for any of these decisions, except inertia. On Mon, Apr 7, 2014 at 8:53 PM, Hilton Bristow notifications@github.comwrote:
|
okay. Same for using "%" rather than "format()" for formatting strings? |
That's actually a more deeply entrenched personal preference. I think it On Mon, Apr 7, 2014 at 8:57 PM, Hilton Bristow notifications@github.comwrote:
|
okay, I won't touch any of that |
out of curiosity, what have you currently been using pymatbridge for? |
Mostly interleaving calls to large legacy code-bases in Matlab into ipython On Mon, Apr 7, 2014 at 9:02 PM, Hilton Bristow notifications@github.comwrote:
|
…b.drawnow(). TODO: Allow the EDT to run while zmq is blocking for a request
…ped minor version number to signify new API
Hey, what framework do you use for testing? I see that your test cases don't subclass |
Indeed. We use On Wed, Apr 9, 2014 at 11:38 PM, Hilton Bristow notifications@github.comwrote:
|
This looks like a great addition! Is this ready for testing or should i wait? I have no problems with a few bugs here and there which i would happily report or fix. |
Hey! On Mon, Apr 14, 2014 at 6:48 PM, Martin notifications@github.com wrote:
|
Hey @hbristow - have you had a chance to take a look? If you don't have time to look at this, would you mind rebasing this on top of master, so I could try to work on this? Thanks! |
Hey! On Sun, May 11, 2014 at 7:57 AM, Ariel Rokem notifications@github.comwrote:
|
Alright - now that we have a new release - time to take a deeper look at this! I have a new branch for this up here: https://github.com/arokem/python-matlab-bridge/tree/hbristow-feat-pythonic Rebased on top of the new master and ready to start breaking stuff! |
Hi Ariel, Congratulations on the new release! I think I'll pick this one and start to At the same time I've been reading about the IPython's messaging mechanism Best, 2014-05-28 9:58 GMT-07:00 Ariel Rokem notifications@github.com:
|
Implemented in #145. |
This pull request introduces a new pythonic API to Matlab. The functionality is experimental at the moment. If you like this direction, let me know and I can solidify the implementation and remove deprecated code. Don't merge this pull request in its current state. I want to know what you think before I spend any sizable amount of time on it.
Features
Matlab functions are Python functions
This allows us to use a bunch of builtin Matlab functionality natively rather than rewrite it ourselves
Keyword Arguments
Functions that take optional named arguments using Matlab's name, value hack (plotting, etc) can use Python's native keyword arguments syntax
Number of Output Arguments
The behaviour of many Matlab functions changes depending on how many output arguments are provided (seriously, who thought of that...). An option
nout
argument can be supplied to indicate how many outputs are desiredNative Python docstrings
Help is provided via Python's builtin
help()
function.docstrings are cached, so they are only fetched from Matlab once.
Exceptions
Matlab exceptions are captured and re-raised as Python exceptions to indicate errors
If a non-existent function name is called, that function name is blacklisted so subsequent attempts to call that function immediately throw an exception.
Give it a try!
And let me know what you think