gemseo / wrappers / matlab

matlab_parser module

Definition of the Matlab parser.

Overview

This module contains the MatlabParser which enables to parse Matlab files in order to automatically detect inputs and outputs. This class is basically used through the MatlabDiscipline class in order to build a discipline based on the Matlab function.

Classes:

MatlabParser([full_path])

Parse Matlab file to identify inputs and outputs.

class gemseo.wrappers.matlab.matlab_parser.MatlabParser(full_path=None)[source]

Bases: object

Parse Matlab file to identify inputs and outputs.

Examples

>>> # Parse the matlab function "fucntion.m"
>>> parser = MatlabParser("function.m")
>>> print(parser.inputs)
>>> print(parser.outputs)
Parameters

full_path (Optional[str]) –

The path to the matlab file. If None, the user shall parse the file explicitly.

By default it is set to None.

Return type

None

Attributes:

RE_ARGS

RE_ENCRYPTED_FCT

RE_FILE_FMT

RE_FUNCTION

RE_OUTPUTS

directory

Return the directory of the function.

function_name

Return the name of the function.

inputs

Return the inputs.

outputs

Return the outputs.

Methods:

parse(path)

Parse a .m file in order to get inputs and outputs.

RE_ARGS = re.compile('\\((.*?)\\)')
RE_ENCRYPTED_FCT = re.compile('.*(\\\\.*)*\\.p\\b')
RE_FILE_FMT = re.compile('.*(\\\\.*)*\\.m\\b')
RE_FUNCTION = re.compile('=(.*?)\\(')
RE_OUTPUTS = re.compile('(\\[(.*?)\\])|(function( *?)(.*?)=)')
property directory

Return the directory of the function.

property function_name

Return the name of the function.

property inputs

Return the inputs.

property outputs

Return the outputs.

parse(path)[source]

Parse a .m file in order to get inputs and outputs.

Parameters

path (str) – The path to the matlab file.

Raises

ValueError – Raised if the file is not a matlab function.

Return type

None