A module to allow Python to call functions from a compiled Matlab archive
Project description
libpymcr
libpymcr is a Python module for loading a compiled Matlab ctf
archive and running functions within it in Python.
Whilst there is an official Mathworks binding for Python, libpymcr provides a few benefits over the official package:
- It is compatible with versions of Python not supported by Matlab (e.g. 3.10, 3.11, 3.12). Moreover, the supported Python versions are not locked to the Matlab versions, unlike with the official packages.
- When converting data between Matlab and Python it avoids data copies where ever possible by wrapping the underlying arrays
in the target type (
numpy
or MatlabmxArray
). In the official bindings, a data copy is required when converting data from Python to Matlab (inputs to functions). - It provides a simpler syntax, and if you include the provided
call.m
andcall_python.mex
files in your compiled package, you will also be able to access Matlab objects transparently in Python, and pass Python callables to Matlab to evaluate (e.g. in a fitting routine).
Getting started
You can install the package using:
pip install libpymcr
You must create a compiled Matlab archive (ctf
file) of your program using the
Matlab Compiler SDK toolbox,
using the mcc command:
mcc -W CTF:your_program_name -U mfile1 mfile2 mfile3
Then in Python, you can load this and call the Matlab functions with:
import libpymcr
m = libpymcr.Matlab('your_program_name.ctf')
m.mfile1()
The functions, mfile1
, mfile2
etc. are exposed to Python can can be called as methods of the Matlab()
object.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for libpymcr-0.1.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad4e8907823ed7e6185c385fa9a8f4145f5fd54652f699c9bd2ec99190db5bec |
|
MD5 | 0224308858ea7b947adee789754f00ba |
|
BLAKE2b-256 | 2f7f5b7abc5b1dd85ab650d32ad13b08cb8159a070bf751fb330c5af196e77d6 |
Hashes for libpymcr-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b36368b21f02288128b52deed7e73804c43a76b47e596b33da2b9fb5294f7d3 |
|
MD5 | f6ddd9d3d0397ad893b472b46b6f7532 |
|
BLAKE2b-256 | e52471b9a46ed95b27e8834f6a5eebae63575dd1f575a2028e05bf791f37be19 |
Hashes for libpymcr-0.1.0-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9e7c2711902662947eb96947eb45c15b28117e13219d7332043f21cc8ceff78 |
|
MD5 | 31d5626fa39e3e4206786510097a220b |
|
BLAKE2b-256 | 1af9bb93da0efea5934791ffb204e1fff863b50a0eb81c7b98d2d97c86b3dce8 |