kdavies4 / ModelicaRes

Set up, analyze, and plot Modelica simulations in Python
http://kdavies4.github.io/ModelicaRes/
Other
51 stars 20 forks source link

SyntaxError when importing SimRes #43

Open Enoch23 opened 3 years ago

Enoch23 commented 3 years ago

When trying to import SimRes I receive the following error.

In [1]: from modelicares import SimRes
Traceback (most recent call last):

  File "C:\ProgramData\Miniconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3418, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)

  File "<ipython-input-3-7373672c4d21>", line 1, in <module>
    from modelicares import SimRes

  File "C:\ProgramData\Miniconda3\lib\site-packages\modelicares\__init__.py", line 50, in <module>
    from .simres import SimRes, SimResList, SimResSequence

  File "C:\ProgramData\Miniconda3\lib\site-packages\modelicares\simres.py", line 1723
    if attr == 'value' and len(self) <> self.n_constants:
                                      ^
SyntaxError: invalid syntax

Is there any way to fix this?

Enoch23 commented 3 years ago

Fixing <> to != showed there was the same error in the dymola.py file. I changed that instance accordingly. The next error was one of simulatiors.py using asyncas a variable (line 632 is the first case). This is not allowed in current python versions. As an experiment, I changed all instances of it to async2.

Now I am not getting any further.

In [1]: from modelicares import SimRes

In [2]: sim = SimRes(dir_result)
Traceback (most recent call last):

  File "<ipython-input-10-53487eb4a54c>", line 1, in <module>
    sim = SimRes(dir_result)

  File "C:\ProgramData\Miniconda3\lib\site-packages\modelicares\simres.py", line 956, in __init__
    variables = read(fname, constants_only)

  File "C:\ProgramData\Miniconda3\lib\site-packages\modelicares\_io\dymola.py", line 378, in readsim
    unit = U._units(**nc.Exponents.fromstr(unit_str))

  File "C:\ProgramData\Miniconda3\lib\site-packages\natu\core.py", line 1374, in __call__
    return reduce(lambda x, y: x * y, factors)

NameError: name 'reduce' is not defined

dir_results is the file path to the result.mat file. I somehow got this working on another machine, but I can't remember how. I don't remember having to edit the files ... .

bilderbuchi commented 3 years ago

That last issue is https://github.com/kdavies4/natu/issues/38 afaict.

Enoch23 commented 3 years ago

Okay. So I remembered installing modelicares manually on the other machine. This was due to lack of admin rights to install via github. So I tried it again.

I uninstalled modeliares from elevated anaconda power shell: pip uninstall modelicares then I downloaded modelicares from: http://kdavies4.github.io/ModelicaRes/ installed it from the same power shell (after unpacking and navigating to the folder): python .\setup.py install and WHAM! It works!!!! haha!

Of course the limitations to the matplotlib versions probably still apply. See here: #42 I already had the correct versions installed this time around.