Changeset 13947


Ignore:
Timestamp:
Nov 4, 2019 3:41:04 PM (13 days ago)
Author:
randersson
Message:

#5819 Added a method to deal with list of names being of type bytes while accessing them directly from the class attribute name

File:
1 edited

Legend:

Unmodified
Added
Removed
  • PyFMI/trunk/src/common/io.py

    r13930 r13947  
    116116    Base class for representation of a result file.
    117117    """
     118    def _get_name(self):
     119        return [decode(n) for n in self._name]
     120   
     121    name = property(fget = _get_name)
     122   
    118123    def get_variable_index(self,name):
    119124        """
     
    180185        for ind in alias_index:
    181186            #Get the trial name
    182             trial_name = self.name[ind]
     187            trial_name = self._name[ind]
    183188           
    184189            #Create the derivative name
     
    266271        else:
    267272            raise JIOError('Unsupported separator.')
    268         self.name = name
     273        self._name = name
    269274       
    270275        self.data_matrix = {}
     
    724729        self.model = model
    725730        self.vars = vars
    726         self.name = [var.name for var in vars.values()]
     731        self._name = [var.name for var in vars.values()]
    727732        self.data = {}
    728733        self.data_matrix = data
     
    853858        fid = codecs.open(fname,'r','utf-8')
    854859       
    855         result  = [];
     860        result  = []
    856861     
    857862        # Read Aclass section
     
    873878        #for i in range(0,nLines):
    874879        #    name.append(fid.readline().strip().replace(" ",""))
    875         self.name = name
    876         self.name_lookup = {key:ind for ind,key in enumerate(self.name)}
     880        self._name = name
     881        self.name_lookup = {key:ind for ind,key in enumerate(self._name)}
    877882     
    878883        # Read description section 
     
    11191124        self.raw_name = name
    11201125
    1121         self.name = fmi_util.convert_array_names_list_names_int(name.view(np.int32))
     1126        self._name = fmi_util.convert_array_names_list_names_int(name.view(np.int32))
    11221127        self.dataInfo = self.raw['dataInfo'].transpose()
    1123         self.name_lookup = {key:ind for ind,key in enumerate(self.name)}
    1124        
    1125         self._description = None
    1126        
     1128        self.name_lookup = {key:ind for ind,key in enumerate(self._name)}
     1129       
     1130        self._description = None 
     1131   
    11271132    def _get_description(self):
    11281133        if not self._description:
Note: See TracChangeset for help on using the changeset viewer.