コード例 #1
0
ファイル: scalar.py プロジェクト: will3216/optimization
 def __process__(self):
     try:
         self.data = array(safe_convert(self.raw_value), dtype=self.dtype)
         self.processed = True
     except:
         self.error_code = '99'
     self.error_status = True
     return 
コード例 #2
0
ファイル: scalar.py プロジェクト: will3216/optimization
 def __test__(self):
     if not self.processed:
         self.error_code = ''
         # Check that self.raw_value converts to a numeric type
         self.error_code = '0'
         try:
             safe_convert(self.raw_value)
         except:
             self.error_code = '1'
     else:
         self.error_code = ''
         try:
             self.data.dtype
             self.error_code = self.error_code = '0'
         except:
             self.error_code = self.error_code +'1'
     return
コード例 #3
0
ファイル: table.py プロジェクト: will3216/optimization
    def __test__(self):
        self.error_code = ''
        if not self.processed:
            # The first item in the raw_table list should be index labels from
            # the first domain in list form.
            rows = self.raw_table[0]
            cols = self.raw_table[1]
            table = self.raw_table[2]
            # Check that rows is a list
            if not type(rows) == type([]):
                self.error_code = self.error_code + '1'
            else:
                # Check that all of the row labels correspond to values in the 
                # domain of the row dimension
                temp_char = '0'
                for label in rows:
                    if label not in self.parent.set_values[self.domain[0]]:
                        temp_char = '2'
                        break
                self.error_code = self.error_code + temp_char

            # Check that cols is a list
            if not type(cols) == type([]):
                self.error_code = self.error_code + '1'
            else:
                # Check that all of the col labels correspond to values in the
                # domain of the col dimension
                temp_char = '0'
                for label in cols:
                    if label not in self.parent.set_values[self.domain[1]]:
                        temp_char = '2'
                        break
                self.error_code = self.error_code + temp_char

            # Check that raw_table is a list
            if not type(cols) == type([]):
                self.error_code = self.error_code + '1'
            else:
                # Check that every value in the table safely converts to a
                # to a numeric type.
                
                temp_char = '0'
                for i in table:
                    # Check that each row is a list
                    if not type(i) == type([]):
                        temp_char = '2'
                    for j in i:
                        try:
                            safe_convert(j)
                        except:
                            temp_char = '3'
                            print j
                            break
                        if temp_char == '3':
                            break
                self.error_code = self.error_code + temp_char
        else:
            # Check if the processed data is a numpy array
            try:
                if not type(self.data) == type(array([1, 1])):
                    self.error_code = self.error_code + '1'
                else:
                    self.error_code = self.error_code + '0'
                    if not self.data.dtype == array([], dtype=self.dtype).dtype:
                        self.error_code = self.error_code + '1'
                    else:
                        self.error_code = self.error_code + '0'
            except:
                self.error_code = self.error_code + '2'

            return