Skip to content

Releases: pace-neutrons/libpymcr

v0.1.8

29 Jun 23:22
f861b05
Compare
Choose a tag to compare
v0.1.8 Pre-release
Pre-release

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

30 May 08:59
Compare
Choose a tag to compare
v0.1.7 Pre-release
Pre-release

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 (dicts, lists 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 where nargout is confused if the called function is shadowed (e.g. fit) and it could not determined the maximum nargout.

v0.1.6

26 Apr 00:02
3db5507
Compare
Choose a tag to compare
v0.1.6 Pre-release
Pre-release

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 if class.prop is a plain Matlab struct).
  • 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

02 Oct 12:44
f34229f
Compare
Choose a tag to compare
v0.1.5 Pre-release
Pre-release

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 given nargout in Matlab.py / call.m
  • New get_nlhs algorithm to set nargout parameters uses ast to better parse cases of nested Matlab calls, like m.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 old dis 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 global dict as direct memory address was failing in some nested calls. call_python now creates its own instance of type_converter to avoid a heap memory error when using the Python initialized object from the libpymcr instance. Re-add DEEPBIND library loading for Linux Lapack/BLAS to avoid conflict with Matlab.

v0.1.4

13 Jun 11:20
38ea9ec
Compare
Choose a tag to compare
v0.1.4 Pre-release
Pre-release

Add IPython magics

Add IPython magics from pace-python (to allow in-line text output and figures in Jupyter notebooks).

v0.1.3

10 Jun 12:38
Compare
Choose a tag to compare
v0.1.3 Pre-release
Pre-release

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

09 Jun 00:51
Compare
Choose a tag to compare
v0.1.2 Pre-release
Pre-release

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

24 Mar 10:17
12e90de
Compare
Choose a tag to compare
v0.1.1 Pre-release
Pre-release

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

22 Mar 03:44
d2f53fe
Compare
Choose a tag to compare
Initial release Pre-release
Pre-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.