fast-aircraft-design / FAST-OAD

FAST-OAD: An open source framework for rapid Overall Aircraft Design
GNU General Public License v3.0
47 stars 25 forks source link

DataFile.from_*() methods return a VariableList instance #421

Closed christophe-david closed 1 year ago

christophe-david commented 2 years ago

Describe the bug Methods like DataFile.from_dataframe() or DataFile.from_ivc() return a VariableList instance instead of a DataFile instance.

To Reproduce

import fastoad.api as oad
import openmdao.api as om

ivc = om.IndepVarComp("my_var")
result = oad.DataFile.from_ivc(ivc)
print(type(result))

returns

<class 'fastoad.openmdao.variables.variable_list.VariableList'>

Expected behavior The snippet above should return <class 'fastoad.io.variable_io.DataFile'>. More generally, any subclass of VariableList should return an instance of the subclass when using this methods.

christophe-david commented 2 years ago

The fix is not complete. The problem still stands for DataFile.from_problem(). The problem comes from the __add__ magic method of VariableList.