gemseo_matlab

Hide inherited members

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.

class gemseo_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 (str | None) – The path to the matlab file. If None, the user shall parse the file explicitly.

parse(path)[source]

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

Parameters:

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

Raises:

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

Return type:

None

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: Path

Return the directory of the function.

property function_name: str

Return the name of the function.

property inputs: list[str]

Return the inputs.

property outputs: list[str]

Return the outputs.