ModelicaRes icon indicating copy to clipboard operation
ModelicaRes copied to clipboard

Problems with natu library

Open fran-jo opened this issue 7 years ago • 2 comments

Hello again!

I am having this error when importing SimRes

Traceback (most recent call last):
  File "C:\Users\fragom\PhD_CIM\PYTHON\SimuGUI\src\gui\msv_framework_gui.py", line 11, in <module>
    from gui import UI_LoadSources, UI_ConfigSolver, UI_Simulation, UI_Plot
  File "C:\Users\fragom\PhD_CIM\PYTHON\SimuGUI\src\gui\__init__.py", line 3, in <module>
    from mee_simulation_gui import UI_Simulation
  File "C:\Users\fragom\PhD_CIM\PYTHON\SimuGUI\src\gui\mee_simulation_gui.py", line 13, in <module>
    from modelicares import SimRes
  File "C:\IDE\Python27\lib\site-packages\modelicares-0.12.2_126_gdab068a-py2.7.egg\modelicares\__init__.py", line 50, in <module>
    from .simres import SimRes, SimResList, SimResSequence
  File "C:\IDE\Python27\lib\site-packages\modelicares-0.12.2_126_gdab068a-py2.7.egg\modelicares\simres.py", line 52, in <module>
    from natu import core as nc
  File "C:\IDE\Python27\lib\site-packages\natu-0.12.2_126_gdab068a-py2.7.egg\natu\core.py", line 171, in <module>
    from .exponents import Exponents, split_code, u, i
  File "C:\IDE\Python27\lib\site-packages\natu-0.12.2_126_gdab068a-py2.7.egg\natu\exponents.py", line 177, in <module>
    parser = re.compile('%s%s?%s?' % (base, exponent, remainder))
  File "C:\IDE\Python27\lib\re.py", line 190, in compile
    return _compile(pattern, flags)
  File "C:\IDE\Python27\lib\re.py", line 245, in _compile
    raise error, v # invalid expression
sre_constants.error: nothing to repeat

I am reading in "the web" that this issue might come from the re.compile() function. I guess you did not face this issue with the natu library. Any idea?

Edited: I am running the code in Eclipse Mars PyDev, under Windows 7

Cheers!

fran-jo avatar Jul 07 '17 14:07 fran-jo

I read in "the web" that might be a possible bug of python ... I've just updated to the last 2.7 version and this problem is not present any more... However, natu keeps complaining, now with this:

Traceback (most recent call last):
  File "C:\Users\fragom\PhD_CIM\PYTHON\SimuGUI\src\gui\msv_framework_gui.py", line 70, in plotSimulation
    simmodel = SimRes('./res/dy/Two_Areas_PSSE_AVR_Noise_dassl_dsin.mat')
  File "C:\IDE\Python27\lib\site-packages\modelicares-0.12.2_126_gdab068a-py2.7.egg\modelicares\simres.py", line 956, in __init__
    variables = read(fname, constants_only)
  File "C:\IDE\Python27\lib\site-packages\modelicares-0.12.2_126_gdab068a-py2.7.egg\modelicares\_io\dymola.py", line 378, in readsim
    unit = U._units(**nc.Exponents.fromstr(unit_str))
  File "C:\IDE\Python27\lib\site-packages\natu-0.12.2_126_gdab068a-py2.7.egg\natu\core.py", line 1373, in __call__
    factors = [self[base] ** exp for base, exp in factors.items()]
  File "C:\IDE\Python27\lib\site-packages\natu-0.12.2_126_gdab068a-py2.7.egg\natu\core.py", line 1433, in __getitem__
    raise error
KeyError: "MV isn't a valid prefix."

I assume that the variables of the model have to have their units defined. But some models might not properly define the units. Is there any way to bypass this? Or should I require the models to be very-well defined instead?

fran-jo avatar Jul 07 '17 16:07 fran-jo

@kdavies4 Any hints on how to solve this?

fran-jo avatar Sep 19 '17 16:09 fran-jo