def test_weighted_catchment_run_again_and_test_overwrite(self):
     catchment = .5
     weight = 1
     result = self.model.weighted_catchment(name='test',
                                            weight_fn=weights.step_fn(
                                                {catchment: weight}))
     result = self.model.weighted_catchment(name='test',
                                            weight_fn=weights.step_fn(
                                                {catchment: weight}))
     actual = result.iloc[0]['test_value']
     self.assertEqual(actual, 1)
Beispiel #2
0
    def test_three_stage_floating_catchment_area_large_catchment_normalize(
            self):
        wfn = weights.step_fn({10: 25})
        result = self.model.three_stage_fca(weight_fn=wfn, normalize=True)
        actual = self.model.access_df.iloc[0]['3sfca_value']

        self.assertEqual(actual, 25)
Beispiel #3
0
    def test_three_stage_floating_catchment_area_small_catchment(self):
        small_catchment = .9
        wfn = weights.step_fn({10: 25})
        result = self.model.three_stage_fca(max_cost=small_catchment,
                                            weight_fn=wfn)
        actual = self.model.access_df.iloc[0]['3sfca_value']

        self.assertEqual(actual, 1)
Beispiel #4
0
    def test_three_stage_floating_catchment_area_large_catchment_run_again_and_test_overwrite(
            self):
        wfn = weights.step_fn({10: 25})
        result = self.model.three_stage_fca(weight_fn=wfn)
        result = self.model.three_stage_fca(weight_fn=wfn)
        actual = self.model.access_df.iloc[0]['3sfca_value']

        self.assertEqual(actual, 25)
 def test_weighted_catchment_small_catchment_weight_x(self):
     catchment = .5
     weight = .5
     result = self.model.weighted_catchment(name='test',
                                            weight_fn=weights.step_fn(
                                                {catchment: weight}))
     actual = result.iloc[0]['test_value']
     self.assertEqual(actual, .5)
 def test_weighted_catchment_large_catchment_weight_1(self):
     catchment = 10
     weight = 1
     result = self.model.weighted_catchment(name='test',
                                            weight_fn=weights.step_fn(
                                                {catchment: weight}))
     actual = result.iloc[0]['test_value']
     self.assertEqual(actual, 25)
Beispiel #7
0
    def test_step_fn_all_weight_two_equals_twice(self):
        weight_fn = weights.step_fn({self.r_int: 2})
        w_applied = self.apply_weight_fn(weight_fn)

        expected = w_applied.sum()
        actual = self.series.sum() * 2

        self.assertEqual(expected, actual)
Beispiel #8
0
    def test_step_fn_all_weight_half_equals_half(self):
        weight_fn = weights.step_fn({self.r_int: .5})
        w_applied = self.apply_weight_fn(weight_fn)

        expected = w_applied.sum()
        actual = self.series.sum() / 2

        self.assertEqual(expected, actual)
Beispiel #9
0
    def test_step_fn_non_dict_input_raises_error(self):
        with self.assertRaises(TypeError):
            weights.step_fn(1)

        with self.assertRaises(TypeError):
            weights.step_fn('a')

        with self.assertRaises(TypeError):
            weights.step_fn([])

        with self.assertRaises(TypeError):
            weights.step_fn(1.0)
Beispiel #10
0
 def test_step_fn_negative_weight_raises_error(self):
     with self.assertRaises(ValueError):
         weight_fn = weights.step_fn({self.r_int: -1})
Beispiel #11
0
    def test_step_fn_all_weight_zero_equals_zero_sum(self):
        weight_fn = weights.step_fn({self.r_int: 0})
        w_applied = self.apply_weight_fn(weight_fn)

        expected = w_applied.sum()
        self.assertEqual(expected, 0)