def test_ttf_formater_should_return_the_original_ttfs_from_87_to_250(self):
     optional_arguments = OptionalArguments(**{'initial_sample': 13})
     formated_data = self.ttf_formater.give_format(self.ntds_data,
                                                   optional_arguments)
     original_ttf = formated_data.get_original_times()
     expected = self.ntds_data.get_data()[13:]
     self.assertListEqual(expected, original_ttf)
 def test_fpd_formater_should_return_the_original_times_of_the_mixed_dataset(
         self):
     optional_arguments = OptionalArguments()
     formated_data = self.fpd_formater.give_format(self.mixed_data,
                                                   optional_arguments)
     original_times = formated_data.get_original_times()
     self.assertListEqual(self.mixed_data.get_times(), original_times)
コード例 #3
0
 def fit(self, stage, fit_strategy, data, stage_number, **kwargs):
     data_formater = self.obtain_data_formater(data.get_format())
     initial_sample = data_formater.determine_stage_initial_sample(
         data, stage.get_initial_t())
     end_sample = data_formater.determine_stage_end_sample(
         data, stage.get_end_t())
     t0 = data_formater.determine_stage_t0(data, stage.get_initial_t())
     kwargs_new = {
         'initial_sample': initial_sample,
         'end_sample': end_sample,
         't0': t0,
         'lsq_only': kwargs.get('lsq_only')
     }
     initial_approx = stage.get_optional_arguments().get_initial_approx()
     if initial_approx is not None:
         kwargs_new['initial_approx'] = initial_approx
     optional_arguments = OptionalArguments(**kwargs_new)
     try:
         stage_lsq_params, stage_ml_params = fit_strategy.fit_model(
             optional_arguments)
         return stage.be_fitted(fit_strategy, optional_arguments,
                                stage_lsq_params, stage_ml_params)
     except InvalidFitException as error:
         raise InvalidFitException(
             str('Stage ' + str(stage_number) + ': ' + error.strerror))
 def test_ttf_formater_should_return_the_cumulative_failures_of_the_dataset(
         self):
     optional_arguments = OptionalArguments()
     formated_data = self.ttf_formater.give_format(self.ntds_data,
                                                   optional_arguments)
     expected = list(range(1, len(self.ntds_data.get_data()) + 1))
     cumulative_failures = formated_data.get_cumulative_failures()
     self.assertListEqual(expected, cumulative_failures)
 def test_ttf_formater_should_format_the_ttfs_with_the_corresponding_t0_if_initial_sample_is_not_zero_and_t0_is_not_specified(
         self):
     optional_arguments = OptionalArguments(**{'initial_sample': 13})
     formated_data = self.ttf_formater.give_format(self.ntds_data,
                                                   optional_arguments)
     formated_ttf = formated_data.get_formated_times()
     expected = self.ntds_data.get_data()[12:]
     self.assertListEqual(expected, formated_ttf)
 def test_ttf_formater_should_format_the_ttfs_with_specified_t0_at_its_beginning(
         self):
     optional_arguments = OptionalArguments(**{'t0': 10})
     formated_data = self.ttf_formater.give_format(self.ntds_data,
                                                   optional_arguments)
     formated_ttf = formated_data.get_formated_times()
     expected = [10] + self.ntds_data.get_data()
     self.assertListEqual(expected, formated_ttf)
 def test_fpd_formater_should_return_the_cumulative_failures_of_the_dataset(
         self):
     optional_arguments = OptionalArguments()
     formated_data = self.fpd_formater.give_format(self.mixed_data,
                                                   optional_arguments)
     expected = self.mixed_data.get_cumulative_failures()
     cumulative_failures = formated_data.get_cumulative_failures()
     self.assertListEqual(expected, cumulative_failures)
 def test_fpd_formater_should_format_the_times_with_a_0_at_its_beginning_if_t0_not_specified(
         self):
     optional_arguments = OptionalArguments()
     formated_data = self.fpd_formater.give_format(self.mixed_data,
                                                   optional_arguments)
     formated_times = formated_data.get_formated_times()
     expected = [0] + self.mixed_data.get_times()
     self.assertListEqual(expected, formated_times)
 def test_fpd_formater_should_return_the_original_times_from_20_to_end(
         self):
     optional_arguments = OptionalArguments(**{'initial_sample': 19})
     formated_data = self.fpd_formater.give_format(self.mixed_data,
                                                   optional_arguments)
     original_times = formated_data.get_original_times()
     expected = self.mixed_data.get_times()[19:]
     self.assertListEqual(expected, original_times)
コード例 #10
0
 def test_fpd_formater_should_format_the_times_with_the_corresponding_t0_if_initial_sample_is_not_zero_and_t0_is_not_specified(
         self):
     optional_arguments = OptionalArguments(**{'initial_sample': 19})
     formated_data = self.fpd_formater.give_format(self.mixed_data,
                                                   optional_arguments)
     formated_times = formated_data.get_formated_times()
     expected = self.mixed_data.get_times()[18:len(self.mixed_data.
                                                   get_times())]
     self.assertListEqual(expected, formated_times)
コード例 #11
0
 def test_ttf_formater_should_return_the_cumulative_failures_from_13_to_25_when_specified_initial_and_end_samples(
         self):
     optional_arguments = OptionalArguments(**{
         'initial_sample': 13,
         'end_sample': 25
     })
     formated_data = self.ttf_formater.give_format(self.ntds_data,
                                                   optional_arguments)
     expected = list(range(14, len(self.ntds_data.get_data()) + 1))
     cumulative_failures = formated_data.get_cumulative_failures()
     self.assertListEqual(expected, cumulative_failures)
コード例 #12
0
 def test_fpd_formater_should_return_the_cumulative_failures_from_20_to_40_when_specified_initial_and_end_samples(
         self):
     optional_arguments = OptionalArguments(**{
         'initial_sample': 19,
         'end_sample': 39
     })
     formated_data = self.fpd_formater.give_format(self.mixed_data,
                                                   optional_arguments)
     expected = self.mixed_data.get_cumulative_failures()[19:40]
     cumulative_failures = formated_data.get_cumulative_failures()
     self.assertListEqual(expected, cumulative_failures)
コード例 #13
0
 def test_ttf_formater_should_return_the_ttfs_from_87_to_250_with_specified_t0_at_its_beginning(
         self):
     optional_arguments = OptionalArguments(**{
         't0': 10,
         'initial_sample': 13,
         'end_sample': 25
     })
     formated_data = self.ttf_formater.give_format(self.ntds_data,
                                                   optional_arguments)
     formated_ttf = formated_data.get_formated_times()
     expected = [10] + self.ntds_data.get_data()[13:]
     self.assertListEqual(expected, formated_ttf)
コード例 #14
0
 def test_ttf_formater_should_return_the_original_ttfs(self):
     optional_arguments = OptionalArguments()
     formated_data = self.ttf_formater.give_format(self.ntds_data,
                                                   optional_arguments)
     original_ttf = formated_data.get_original_times()
     self.assertListEqual(self.ntds_data.get_data(), original_ttf)
コード例 #15
0
 def decode_kwargs(self, **kwargs):
     return OptionalArguments(**kwargs)