Releases: pace-neutrons/libpymcr
v0.1.8
Bugfixes
- Implements a workaround for a changed
mxArray
layout in R2023b and newer (disables wrapping of Matlab arrays in Python). - Fixes issues with inline plots in Jupyter notebooks
- Fix an issue with errors for Matlab functions which do not return any values, and an issue with recursive dot indexing
v0.1.7
New Features
Add a command matlab2python
which generates Python wrappers for Matlab code in a specified directory (syntax is similar to mcc
).
By default the Python wrappers are created in a package folder called matlab_wrapped
.
If you have a package and want to call the Matlab functions without the m.
prefix, you can do:
from matlab_wrapped import *
Matlab class properties which are standard types (dict
s, list
s and numpy arrays) are now better supported by a fix to DictPropertyWrapper
and a new VectorPropertyWrapper
, which allows syntax like:
obj.prop['a'] = 1
obj.prop[1] = 2
Matlab column vectors can be indexed with a single index (rather than requiring a tuple as in obj.prop[1,2]
which numpy requires).
Bugfixes
Bugfixes for some issues arising from testing in preparation for EDATC2
- Update matlab checker to be more robust and to output a warning of a licensed Matlab was found but the Compiler SDK toolbox is not installed.
- Fix
MatlabProxyObject
dunder methods to work with libpymcr. - Fix
MatlabProxyObject
indexing bug where libpymcr converted the old list to a vector instead of a cell-array (now uses a tuple). - Fix a bug in
call.m
wherenargout
is confused if the called function is shadowed (e.g.fit
) and it could not determined the maximumnargout
.
v0.1.6
Bugfixes
Bugfixes for various user reported issues when used with pace-python and PySpinW.
- Add search of
matlab
executable on path for Linux. - Add a
type
method to interrogate Matlab type (fixes issue with pace-python-demo example) - Add a proxy to allow plain struct properties of a class to be manipulated like in Matlab (so
class.prop.subprop = 1
will work ifclass.prop
is a plain Matlabstruct
). - Change to using
evalAsync
in Matlab and as part of this polls the output streams every 1ms and prints output to Python - this allows synchronous output to both console, Jupyter and Spyder without additional code.
v0.1.5
Bugfixes for PySpinW
Bugfixes for PySpinW identified by users and during the RAL-India workshop.
- Fix a segfault when temporary numpy arrays are re-used multiple times in definition of SpinW objects
- Change behaviour of tuples and lists. Python tuples now always convert to Matlab cells. Nested lists will convert to Matlab numeric arrays if they are consistent in shape and contain only numbers. This allows Python
([1,2,3], [4,5,6])
to convert to Matlab{[1 2 3] [4 5 6]}
whereas before it would have converted to Matlab[1 2 3; 4 5 6]
. Python[[1,2,3], [4,5,6]]
will still convert to Matlab[1 2 3; 4 5 6]
. - Fix bug where Matlab commands which return zero outputs fail, e.g.
m.axis([0,1,0,1])
due to incorrectly givennargout
in Matlab.py / call.m - New
get_nlhs
algorithm to setnargout
parameters usesast
to better parse cases of nested Matlab calls, likem.eig(m.rand(3))
but this only works if the full command is on one line; and also does not work for the basic interpreter (but should work in Mantid, Jupyter and Spyder). For those cases, the olddis
algorithm is used, updated to work with Python 3.11 but does not handle nested calls. - Fix bugs in
call_python
. Changed mechanism back to using a globaldict
as direct memory address was failing in some nested calls.call_python
now creates its own instance oftype_converter
to avoid a heap memory error when using the Python initialized object from thelibpymcr
instance. Re-addDEEPBIND
library loading for Linux Lapack/BLAS to avoid conflict with Matlab.
v0.1.4
v0.1.3
Bugfixes for PySpinW
Further bugfixes for PySpinW - now automatically converts unnested lists and numpy vectors to row-vectors in Matlab to be consistent with Matlab convention (previously had converted to column vectors using Fortran convention).
v0.1.2
Bugfixes for PySpinW
A set of bugfixes and a new feature for the PySpinW beta
- Fix error when caller is
a.bc(de, f=gh)
- Fix typo in nested dot indexing call
- Add new automatic conversion of nested lists into N-D matlab arrays
E.g.
m.eig([[1,2,3], [4,5,6], [7,8,9]])
now correctly converts the nested list into a 3x3 matrix and the eig
function no longer gives an error.
v0.1.1
Initial public beta of libpymcr
Basic support for running compiled Matlab apps within Python. Example:
from libpymcr import _libpymcr
m = _libpymcr('/path/to/ctf')
m.magic(3)
would yield:
array([[8., 1., 6.],
[3., 5., 7.],
[4., 9., 2.]])
if you included the magic
function in your ctf
archive.
There is a gateway function call.m
which if you include in your ctf
archive
will allow any Matlab built-in functions to be called (internally using feval
).
libpymcr
runs on Python 3.7 -- 3.11, and Matlab releases R2020a -- R2022b.
Initial release
Initial release of libpymcr, a library to load and run functions from a compiled Matlab ctf archive. This is a rewrite of the core code of pace-python, dealing with the Python-Matlab interface only.