Exemplo n.º 1
0
 def _info(self):
     '''
     Method to summarize the results for alpha.
     return generator of tuples(title:str, item)
     '''
     if self.name:
         yield ('Name', self.name)
     if self.value is not None:
         _index = (f'Sensor {m+1}' for m in range(self.value.shape[0]))
         _columns = (f'Plane {n+1}' for n in range(self.value.shape[1]))
         yield ('Coefficient Values',
                pd.DataFrame(tools.convert_cart_math(self.value),
                             index=_index,
                             columns=_columns))
     if self.A is not None:
         _index = (f'Sensor {m+1}' for m in range(self.A.shape[0]))
         yield ('Initial Vibration',
                pd.DataFrame(tools.convert_cart_math(self.A),
                             index=_index,
                             columns=['Vibration']))
     if self.B is not None:
         _index = (f'Sensor {m+1}' for m in range(self.B.shape[0]))
         _columns = (f'Plane {n+1}' for n in range(self.B.shape[1]))
         yield ('Trial Runs Vibration',
                pd.DataFrame(tools.convert_cart_math(self.B),
                             index=_index,
                             columns=_columns))
     if self.U is not None:
         _index = (f'Plane {n+1}' for n in range(self.U.shape[0]))
         yield ('Trial Masses',
                pd.DataFrame(tools.convert_cart_math(self.U),
                             index=_index,
                             columns=['Mass']))
        def error(self, options='error'):
            '''
            Method to determine different ways of error in the splitting.
            Args:
                Instance of split model
                options: kwarg to define the type of error.
                'error': default value returns the relative value of error.
                'problem_error': returns the accuracy of the solution.
                'equ': returns the equivilant weight of splitting solution
                    in math form.
            '''

            # Error equivilant weight after splitting
            _error = abs(self._W_equ_split - self.weight)
            # Estimate the error generated by using minmax instead of norm2 in the objective function
            _problem_error = (self._prob_S - _error) / abs(self.weight)
            if options == 'error':
                return _error
            elif options == 'problem_error':
                return _problem_error
            elif options == 'equ':
                return tools.convert_cart_math(self._W_equ_split)
            else:
                raise tools.CustomError(
                    'Invalid options. Choose options="error" for solution error'
                    'caused by splitting, options="problem_error" for solution'
                    ' accuracy and options="equ" for equivilant weight.')
    def _info(self):
        '''
        Method to summarize the results for Model.
        '''
        yield ('MODEL TYPE', type(self).__name__)
        if self.name:
            yield ('MODEL NAME', self.name)
        if self.alpha is not None:
            yield ('INFLUENCE COEFFICIENT MATRIX', str(self.alpha))
        if self.A is not None and self.conditions is None:
            _index = (f'Sensor {m+1}' for m in range(self.A.shape[0]))
            yield ('INITIAL VIBRATION',
                   pd.DataFrame(tools.convert_cart_math(self.A),
                                index=_index,
                                columns=['Vibration']))
        if self.conditions is not None:
            yield ('CONDITIONS',
                   ''.join(str(condition) for condition in self.conditions))
        if self.W is not None:
            _index = (f'Plane {n+1}' for n in range(self.W.shape[0]))
            yield ('SOLUTION',
                   pd.DataFrame(tools.convert_cart_math(self.W),
                                index=_index,
                                columns=['Correction Masses']))
            yield ('RMSE', self.rmse())
            _index = (f'Sensor {m+1}' for m in range(self.A.shape[0]))
            yield ('Resiudal Vibration Expected',
                   pd.DataFrame(tools.convert_cart_math(
                       self.expected_residual_vibration()),
                                index=_index,
                                columns=['Expected Vibration']))
        else:
            yield ('SOLUTION', 'No solution calculated.')

        if self.split_instance is not None:
            if self.split_instance:
                yield ('SPLITS', '\n\n'.join(
                    str(split.results()) for split in self.split_instance))
Exemplo n.º 4
0
 def _info(self):
     '''
     Method to summarize the results for condition.
     '''
     if self.name:
         yield ('Name', self.name)
     if self.alpha is not None:
         yield ('Condition IC Matrix', str(self.alpha))
     if self.A is not None:
         _index = (f'Sensor {m+1}' for m in range(self.A.shape[0]))
         yield ('Initial Vibration',
                pd.DataFrame(tools.convert_cart_math(self.A),
                             index=_index,
                             columns=['Vibration']))
def test_convert_cart_math(param, expected):

    output = tools.convert_cart_math(complex(param))
    assert expected == str(output)