Exemplo n.º 1
0
 def test_too_many_appliances_ownership_from_dict(self):
     """Checks that ownership of a i-eth app that is not planned gives 0.
     """
     ownership_dict = {'app': 0.3, 'app_2': 0.2}
     appliances_dict = {'type': ['app', 'app', 'app', 'app']}
     probs = get_ownership_from_dict(appliances_dict, ownership_dict)
     self.assertTrue(np.all(probs == np.array([0.3, 0.2, 0.0, 0.0])))
Exemplo n.º 2
0
 def test_ownership_from_dict_doc(self):
     # code snippet of the documentation
     appliances_dict = {'type': ['hob', 'electric_hob']}
     ownership_dict = {'hob': 0.9, 'hob_2': 0.1}
     probs = get_ownership_from_dict(appliances_dict, ownership_dict)
     print(probs)
     self.assertTrue(np.all(probs == np.array([0.9, 0.1])))
Exemplo n.º 3
0
 def test_complex_ownership_from_dict(self):
     ownership_dict = {'app': 0.3, 'app_2': 0.2, 'app_3': 0.1}
     appliances_dict = {
         'type': [self.long_type, self.single_type, self.long_type]
     }
     probs = get_ownership_from_dict(appliances_dict, ownership_dict)
     print(probs)
     self.assertTrue(np.all(probs == np.array([0.3, 0.2, 0.1])))
Exemplo n.º 4
0
 def test_ownership(self, version=None):
     from demod.datasets.CREST.loader import Crest
     data = Crest() if version is None else Crest(version)
     ownership_dict = data.load_appliance_ownership_dict()
     from demod.utils.appliances import get_ownership_from_dict
     values = get_ownership_from_dict(
         {'type': ['chest_freezer', 'tv', 'tv', 'tv']}, ownership_dict)
     self.assertTrue(np.all(values == np.array([0.163, 0.977, 0.58, 0.18])))