ModelicaRes import fails in python

Question:

I want to use ModelicaRes to open my Dymola results in python but the import fails.

from modelicares.simres import SimRes

Gives the following error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In [2], line 1
----> 1 from modelicares.simres import SimRes

File C:ProgramDataMiniforge3envsmainlibsite-packagesmodelicares__init__.py:54
     40 __version__ = '0.12.2'
     43 # Standard pylint settings for this project:
     44 # pylint: disable=I0011, C0302, C0325, R0903, R0904, R0912, R0913, R0914, R0915,
     45 # pylint: disable=I0011, W0141, W0142
   (...)
     52 # These will be available directly from modelicares; others must be loaded from
     53 # their submodules.
---> 54 from modelicares.simres import SimRes, SimResList
     55 from modelicares.linres import LinRes, LinResList
     56 from modelicares.util import (add_arrows, add_hlines, add_vlines, ArrowLine,
     57                               closeall, multiglob, figure, load_csv, save,
     58                               saveall, setup_subplots)

File C:ProgramDataMiniforge3envsmainlibsite-packagesmodelicaressimres.py:50
     48 from itertools import cycle
     49 from matplotlib import rcParams
---> 50 from matplotlib.cbook import iterable
     51 from matplotlib.pyplot import figlegend
     52 from pandas import DataFrame

ImportError: cannot import name 'iterable' from 'matplotlib.cbook' (C:ProgramDataMiniforge3envsmainlibsite-packagesmatplotlibcbook__init__.py)

I tried DyMat and Buildingspy but I would prefer to use ModelicaRes. Because Buildingspy makes use of DyMat which is quiet old and seems unmaintained.

Asked By: Hannah_Julia

||

Answers:

I also had this issue.

I fixed this in my fork of modelicares here: https://github.com/sede-fa/ModelicaRes

I basically replaced any reference to matplotlib.cbook to numpy to get the iterable function as shown here: https://github.com/kdavies4/ModelicaRes/issues/42

You can install this via pip by doing: pip install git+https://github.com/sede-fa/ModelicaRes.git

Answered By: Faisal