# oct2py **Repository Path**: zhufengGNSS/oct2py ## Basic Information - **Project Name**: oct2py - **Description**: Run M Files from Python - GNU Octave to Python bridge - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2020-11-25 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README Oct2Py: Python to GNU Octave Bridge =================================== .. image:: https://badge.fury.io/py/oct2py.png/ :target: http://badge.fury.io/py/oct2py .. image:: https://codecov.io/github/blink1073/oct2py/coverage.svg?branch=master :target: https://codecov.io/github/blink1073/oct2py?branch=master .. image:: http://pepy.tech/badge/oct2py :target: http://pepy.tech/project/oct2py :alt: PyPi Download stats Oct2Py allows you to seamlessly call M-files and Octave functions from Python. It manages the Octave session for you, sharing data behind the scenes using MAT files. Usage is as simple as: .. code-block:: python >>> oc = oct2py.Oct2Py() >>> x = oc.zeros(3,3) >>> print(x, x.dtype) [[ 0. 0. 0.] [ 0. 0. 0.] [ 0. 0. 0.]] float64 ... To run .m function, you need to explicitly add the path to .m file using: .. code-block:: python >>> from oct2py import import octave >>> # to add a folder use: >>> octave.addpath('/path/to/directory') >>> # to add folder with all subfolder in it use: >>> octave.addpath(octave.genpath('/path/to/directory')) ... To get the output of .m file after setting the path, use: .. code-block:: python >>> x = np.array([[1, 2], [3, 4]], dtype=float) >>> #use nout='max_nout' to automatically choose max possible nout >>> out, oclass = octave.roundtrip(x,nout=2) >>> import pprint >>> pprint.pprint([x, x.dtype, out, oclass, out.dtype]) [array([[1., 2.], [3., 4.]]), dtype('float64'), array([[1., 2.], [3., 4.]]), 'double', dtype('