meg

A MATLAB engine connector in Python

https://github.com/lamyj/meg

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.8%) to scientific vocabulary

Keywords

bridge engine matlab python
Last synced: 6 months ago · JSON representation

Repository

A MATLAB engine connector in Python

Basic Info
  • Host: GitHub
  • Owner: lamyj
  • License: mit
  • Language: Python
  • Default Branch: master
  • Size: 39.1 KB
Statistics
  • Stars: 2
  • Watchers: 2
  • Forks: 1
  • Open Issues: 0
  • Releases: 0
Topics
bridge engine matlab python
Created about 6 years ago · Last pushed almost 2 years ago
Metadata Files
Readme License

README.md

Meg: a MATLAB engine connector in Python

PyPI - Wheel

Meg is a Python module to interface with the MATLAB engine, allowing to transfer data between Python and MATLAB, and to call MATLAB code from Python.

Assuming you can run matlab from the command line (i.e. the main MATLAB executable is in your PATH), using Meg is as simple as:

```python import meg import numpy

with meg.Engine() as engine: data = numpy.empty((4,3))

# Copy Python data to the engine
engine["data"] = data

# Execute MATLAB instructions
engine("count = numel(data)")

# Get data from MATLAB
print(engine["count"])

```

Meg can be installed as any Python package: get the latest stable version from PyPi using pip (e.g. python3 -m pip install meg) or clone the source code and add it to your Python path.

Connecting to MATLAB

The main workhorse of Meg is the Engine object: it must be started before sending data between Python and MATLAB. An engine can be started (and automatically stopped) using the following syntax:

```python import meg

with meg.Engine() as engine: # Interact with MATLAB pass

Once we reach this point, the engine has been automatically stopped.

```

Note that once an engine is stopped, all data stored inside which has not been transfered to Python is lost.

It is also possible to manually start and stop the engine: ```python import meg

Create the engine, but do not start it

engine = meg.Engine()

engine.open()

Interact with MATLAB

engine.close() ```

For more complicated environment (e.g. multiple versions of MATLAB, executable not in PATH, etc.), it is possible to specify the root directory of your target installation of MATLAB, and the explicit command to run when starting the engine:

```python import meg

Target a specific installation of MATLAB

meg.setup("/opt/MATLAB/R2012b")

Start the engine with a non-default command

with meg.Engine("/opt/MATLAB/R2012b/bin/matlab -nosplash") as engine: pass ```

Getting data to and from MATLAB

Data can be exchanged between Python and MATLAB using the Engine object: to store the content of the Python object name foo in the MATLAB object called bar, simply write engine["bar"] = foo. The reverse operation (storing the content of the MATLAB object called bar to a Python object called foo), write foo = engine["bar"].

Numbers (and number containers) are translated as-is between MATLAB and Python. From Python, list, tuples and numpy arrays will be converted to MATLAB numeric arrays; from MATLAB, numeric arrays will be converted either to Python scalars or to numpy arrays.

From Python, heterogeneous containers (lists, tuples or numpy arrays containing object of different types) will be converted to MATLAB cell arrays; from MATLAB, cell arrays will be converted to numpy arrays.

From Python, dictionaries and structured numpy arrays are converted to MATLAB struct arrays, and the same applies to the reverse conversion.

Calling MATLAB code

MATLAB statements are run by calling the engine object: assuming you have stored an object called x in MATLAB, computing the number of elements in it is done through engine("count = numel(x)"). Note that objects are not automatically exchanged between Python and MATLAB: they must be explicitely stored in the MATLAB engine before using them in MATLAB code.

Owner

  • Name: Julien Lamy
  • Login: lamyj
  • Kind: user
  • Company: Université de Strasbourg

GitHub Events

Total
Last Year

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 28
  • Total Committers: 1
  • Avg Commits per committer: 28.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Julien Lamy l****y@u****r 28
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 8 months ago

All Time
  • Total issues: 0
  • Total pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: 40 minutes
  • Total issue authors: 0
  • Total pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
  • megpower1 (2)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 88 last-month
  • Total dependent packages: 1
    (may contain duplicates)
  • Total dependent repositories: 1
    (may contain duplicates)
  • Total versions: 5
  • Total maintainers: 1
pypi.org: meg

MATLAB engine connector

  • Versions: 4
  • Dependent Packages: 1
  • Dependent Repositories: 1
  • Downloads: 88 Last month
Rankings
Dependent packages count: 4.7%
Dependent repos count: 21.7%
Average: 22.3%
Downloads: 27.3%
Stargazers count: 27.8%
Forks count: 29.8%
Maintainers (1)
Last synced: 6 months ago
conda-forge.org: meg

Meg is a Python module to interface with the MATLAB engine, allowing to transfer data between Python and MATLAB, and to call MATLAB code from Python.

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 34.0%
Average: 51.2%
Dependent packages count: 51.2%
Stargazers count: 58.4%
Forks count: 61.1%
Last synced: 6 months ago

Dependencies

setup.py pypi
  • numpy *