Opened 5 years ago

#5612 new defect

OMPython fails to load model in enhanced mode due to ValueError

Reported by: Markus.Bauer@… Owned by: alash325
Priority: critical Milestone: Future
Component: OMPython Version: v1.13.2
Keywords: ValueError, Table, Cc:

Description

Hey,

OMPython throws a ValueError exception when I try to load a modelica model with tables (CombiTimeTable, CombiTable1d) in it. This is thrown in the __init__.py. The code tries to parse the parameters where name is None and the else-clause defaults to convert to float. But some parameters with name None are like filename of the tables mentioned. (are those parameters implicitly generated? More likely it's a problem because I import those tables into my model...)

I fixed it for myself by catching the exception and converting to string instead. I attached the code beginning from line 1094...

Thanks for your support!!

    def __getParameterValues(self, paraName=None):
        """
        This method returns list of values of the quantities name that are parameters. It can be called:
            •without any arguments: return list of values of all quantities (parameter) name
            •with a single argument as parameter name in string format: returns value of the corresponding name
            •with a single argument as list of parameter names in string format: return list of values of the corresponding names.
                1.If the list of names is more than one and it is being assigned by single variable then it returns the list of values of the corresponding names
                2.If the list of names is more than one and it is being assigned by same number of variable as the number of element in the list then it will return the value to the variables correspondingly (python unpacking)
        """

        if paraName is None:
            if not self.pValuesList:
                for l in self.quantitiesList:
                    if (l.variability == "parameter"):
                        str_ = l.start
                        if ((str_ is None) or (str_ == 'true' or str_ == 'false')):
                            if (str_ == 'true'):
                                str_ = True
                            elif str_ == 'false':
                                str_ = False
                            self.pValuesList.append(str_)
                        else:
                            try:
                                self.pValuesList.append(float(str_)) #HOTFIX BAM
                            except ValueError:
                                self.pValuesList.append(str(str_)) #HOTFIX BAM
                                
            return self.pValuesList

Change History (0)

Note: See TracTickets for help on using tickets.