Beispiel #1
0
 def test_process_args_gammapolyv_no_rho0_guess(self):
     with patch.object(ArgumentParser, 'error',
                       return_value=None) as mock_error:
         parser = ArgumentParser()
         io.define_args(parser)
         args = self._get_args(
             parser, **{'fit_type': [cf.GammaPolyV.name_prefix + '2']})
         io.process_args(parser, args)
     mock_error.assert_called_once_with(
         'If using fitter "sandiapc", "gammapoly", or "gammapolyv", you must give a value for "rho0_guess".'
     )
Beispiel #2
0
 def test_process_args_gammapolyv_with_rho0_guess(self):
     with patch.object(ArgumentParser, 'error',
                       return_value=None) as mock_error:
         parser = ArgumentParser()
         io.define_args(parser)
         args = self._get_args(
             parser, **{
                 'fit_type': [cf.GammaPolyV.name_prefix + '2'],
                 'rho0': 5
             })
         io.process_args(parser, args)
     mock_error.assert_not_called()
Beispiel #3
0
    def _define_args(self):
        parser = configargparse.ArgumentParser(
            description='Curve Editor.  Fits a curve to the input data, then '
            'lets user change points and recalculate the curve. '
            '>>Config File<< ',
            epilog='You only need to provide enough of each argument name to '
            'make it unique. e.g. --i and --input_file are equivalent.  '
            'You must provide exactly one source data argument.',
            default_config_files=['curve_editor.ini'],
            # args_for_setting_config_path=['--config_file'],
            # config_arg_help_message='Configuration file path(s) [default: %(default)s].'
            #                         '  Command line parms override config file parms.'
        )
        parser.add_argument('-v',
                            '--version',
                            action='version',
                            version='%(prog)s ' + VERSION_STRING)
        # noinspection PyProtectedMember
        parser.add_argument(
            '--config_file',
            is_config_file=True,
            help='Configuration file path(s) [default: %s].  Command line parms '
            'override config file parms.' % parser._default_config_files,
            metavar='<path>')
        parser.add_argument(
            '--no_config_file',
            help='Do not use any config file, even if a default is provided',
            action='store_true')
        # config_file default is implicitly 'config_file.ini'
        parser.add_argument('--x_label',
                            action='store',
                            nargs=1,
                            default='X',
                            help='Set name of x axis label.')
        parser.add_argument('--y_label',
                            action='store',
                            nargs=1,
                            default='Y',
                            help='Set name of y axis label.')
        io.define_args(parser)
        regions.define_args(parser)
        curve_fitters.define_args(parser)
        window.define_args(parser)

        self._parser = parser