# Path: nilmtk/node.py
# def find_unsatisfied_requirements(state, requirements):
#     """
#     Parameters
#     ----------
#     state, requirements : dict
#         If a property is required but the specific value does not
#         matter then use 'ANY VALUE' as the value in `requirements`.
# 
#     Returns
#     -------
#     list of strings describing (for human consumption) which
#     conditions are not satisfied.  If all conditions are satisfied
#     then returns an empty list.
#     """
#     unsatisfied = []
# 
#     def unsatisfied_requirements(st, req):
#         # Recursively find requirements
#         for key, value in req.items():
#             try:
#                 cond_value = st[key]
#             except KeyError:
#                 msg = ("Requires '{}={}' but '{}' not in state dict."
#                        .format(key, value, key))
#                 unsatisfied.append(msg)
#             else:
#                 if isinstance(value, dict):
#                     unsatisfied_requirements(cond_value, value)
#                 elif value != 'ANY VALUE' and cond_value != value:
#                     msg = ("Requires '{}={}' not '{}={}'."
#                            .format(key, value, key, cond_value))
#                     unsatisfied.append(msg)
# 
#     unsatisfied_requirements(state, requirements)
# 
#     return unsatisfied


import unittest
from ..node import find_unsatisfied_requirements
        self.assertEqual(len(unsatisfied), 1)

        state = {'gaps_located':False, 'energy_computed':False}
        unsatisfied = find_unsatisfied_requirements(state, requirements)
        self.assertEqual(len(unsatisfied), 2)

        state = {}
        unsatisfied = find_unsatisfied_requirements(state, requirements)
        self.assertEqual(len(unsatisfied), 2)

        state = {'gaps_located':True, 'energy_computed':True}
        unsatisfied = find_unsatisfied_requirements(state, requirements)
        self.assertEqual(unsatisfied, [])

        requirements = {'preprocessing': {'gaps_located':True, 'energy_computed':False}}
        state = {'preprocessing': {'gaps_located':True, 'energy_computed':False},
                 'sample_period': 6}
        unsatisfied = find_unsatisfied_requirements(state, requirements)
        self.assertEqual(unsatisfied, [])        
        
        requirements = {'preprocessing': {'gaps_located':True, 'energy_computed':True}}
        state = {'preprocessing': {'gaps_located':True, 'energy_computed':False},
                 'sample_period': 6}
        unsatisfied = find_unsatisfied_requirements(state, requirements)
        self.assertEqual(len(unsatisfied), 1)

        requirements = {'preprocessing': {'gaps_located':True, 'energy_computed':True},
                        'sample_period': 100}
        state = {'preprocessing': {'gaps_located':True, 'energy_computed':False},
                 'sample_period': 6}

# Path: nilmtk/node.py
# def find_unsatisfied_requirements(state, requirements):
#     """
#     Parameters
#     ----------
#     state, requirements : dict
#         If a property is required but the specific value does not
#         matter then use 'ANY VALUE' as the value in `requirements`.
# 
#     Returns
#     -------
#     list of strings describing (for human consumption) which
#     conditions are not satisfied.  If all conditions are satisfied
#     then returns an empty list.
#     """
#     unsatisfied = []
# 
#     def unsatisfied_requirements(st, req):
#         # Recursively find requirements
#         for key, value in req.items():
#             try:
#                 cond_value = st[key]
#             except KeyError:
#                 msg = ("Requires '{}={}' but '{}' not in state dict."
#                        .format(key, value, key))
#                 unsatisfied.append(msg)
#             else:
#                 if isinstance(value, dict):
#                     unsatisfied_requirements(cond_value, value)
#                 elif value != 'ANY VALUE' and cond_value != value:
#                     msg = ("Requires '{}={}' not '{}={}'."
#                            .format(key, value, key, cond_value))
#                     unsatisfied.append(msg)
# 
#     unsatisfied_requirements(state, requirements)
# 
#     return unsatisfied


# Path: nilmtk/tests/test_node.py
import unittest
from ..node import find_unsatisfied_requirements

        self.assertEqual(len(unsatisfied), 1)

        state = {'gaps_located':False, 'energy_computed':False}
        unsatisfied = find_unsatisfied_requirements(state, requirements)
        self.assertEqual(len(unsatisfied), 2)

        state = {}
        unsatisfied = find_unsatisfied_requirements(state, requirements)
        self.assertEqual(len(unsatisfied), 2)

        state = {'gaps_located':True, 'energy_computed':True}
        unsatisfied = find_unsatisfied_requirements(state, requirements)
        self.assertEqual(unsatisfied, [])

        requirements = {'preprocessing': {'gaps_located':True, 'energy_computed':False}}
        state = {'preprocessing': {'gaps_located':True, 'energy_computed':False},
                 'sample_period': 6}
        unsatisfied = find_unsatisfied_requirements(state, requirements)
        self.assertEqual(unsatisfied, [])        
        
        requirements = {'preprocessing': {'gaps_located':True, 'energy_computed':True}}
        state = {'preprocessing': {'gaps_located':True, 'energy_computed':False},
                 'sample_period': 6}
        unsatisfied = find_unsatisfied_requirements(state, requirements)
        self.assertEqual(len(unsatisfied), 1)

        requirements = {'preprocessing': {'gaps_located':True, 'energy_computed':True},
                        'sample_period': 100}
        state = {'preprocessing': {'gaps_located':True, 'energy_computed':False},
                 'sample_period': 6}

        unsatisfied = find_unsatisfied_requirements(state, requirements)