Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions pymatbridge/matlab_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class MatlabMagics(Magics):
"""
def __init__(self, shell,
matlab='matlab',
maxtime=60,
pyconverter=np.asarray):
pyconverter=np.asarray,
**kwargs):
"""
Parameters
----------
Expand All @@ -63,20 +63,19 @@ def __init__(self, shell,
The system call to start a matlab session. Allows you to choose a
particular version of matlab if you want

maxtime : float
The maximal time to wait for responses for matlab (in seconds).
Default: 10 seconds.

pyconverter : callable
To be called on matlab variables returning into the ipython
namespace

kwargs: additional key-word arguments to pass to initialization of
the Matlab/Octave process
"""
super(MatlabMagics, self).__init__(shell)

if 'octave' in matlab.lower():
self.Matlab = pymat.Octave(matlab, maxtime=maxtime)
self.Matlab = pymat.Octave(matlab, **kwargs)
else:
self.Matlab = pymat.Matlab(matlab, maxtime=maxtime)
self.Matlab = pymat.Matlab(matlab, **kwargs)
self.Matlab.start()
self.pyconverter = pyconverter

Expand Down Expand Up @@ -216,4 +215,3 @@ def unload_ipython_extension(ip):
magic = ip.magics_manager.registry.pop('MatlabMagics')
magic.Matlab.stop()
_loaded = False

9 changes: 8 additions & 1 deletion pymatbridge/tests/test_magic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import sys
import os
from uuid import uuid4

import pymatbridge as pymat
from pymatbridge.matlab_magic import MatlabInterperterError
Expand All @@ -19,7 +21,12 @@ def setup_class(cls):
matlab = 'octave'
else:
matlab = 'matlab'
pymat.load_ipython_extension(cls.ip, matlab=matlab)

# We will test the passing of kwargs through to the Matlab or Octave
# objects, by assigning the socket address out here:
socket_addr = "tcp://127.0.0.1" if sys.platform == "win32" else "ipc:///tmp/pymatbridge-%s"%str(uuid4())
pymat.load_ipython_extension(cls.ip, matlab=matlab,
socket_addr=socket_addr)

# Unload the magic
@classmethod
Expand Down