コード例 #1
0
 def test_dependency_with_lowlevel_dependencies_requested(self):
     """ Simulate requesting a Raw Parameter as a dependency. This requires
     the requested node to be removed when it is not at the top of the
     dependency tree.
     """
     requested = ['P7', 'P8', # top level nodes
                  'P4', 'P5', 'P6', # middle level node
                  'Raw3', # bottom level node
                  ]
     mgr = NodeManager({'Start Datetime': datetime.now()}, 10, self.lfl_params + ['Floating'],
                       requested, [], self.derived_nodes, {}, {})
     gr = graph_nodes(mgr)
     gr_all, gr_st, order = process_order(gr, mgr)
     
     self.assertEqual(len(gr_st), 11)
     pos = order.index
     self.assertTrue(pos('P8') > pos('Raw5'))
     self.assertTrue(pos('P7') > pos('P4'))
     self.assertTrue(pos('P7') > pos('P5'))
     self.assertTrue(pos('P7') > pos('P6'))
     self.assertTrue(pos('P6') > pos('Raw3'))
     self.assertTrue(pos('P5') > pos('Raw3'))
     self.assertTrue(pos('P5') > pos('Raw4'))
     self.assertTrue(pos('P4') > pos('Raw1'))
     self.assertTrue(pos('P4') > pos('Raw2'))
     self.assertFalse('Floating' in order)
     self.assertFalse('root' in order) #don't include the root!
コード例 #2
0
    def test_dependency_with_lowlevel_dependencies_requested(self):
        """ Simulate requesting a Raw Parameter as a dependency. This requires
        the requested node to be removed when it is not at the top of the
        dependency tree.
        """
        requested = [
            'P7',
            'P8',  # top level nodes
            'P4',
            'P5',
            'P6',  # middle level node
            'Raw3',  # bottom level node
        ]
        mgr = NodeManager(datetime.now(), 10, self.lfl_params + ['Floating'],
                          requested, [], self.derived_nodes, {}, {})
        gr = graph_nodes(mgr)
        gr_all, gr_st, order = process_order(gr, mgr)

        self.assertEqual(len(gr_st), 11)
        pos = order.index
        self.assertTrue(pos('P8') > pos('Raw5'))
        self.assertTrue(pos('P7') > pos('P4'))
        self.assertTrue(pos('P7') > pos('P5'))
        self.assertTrue(pos('P7') > pos('P6'))
        self.assertTrue(pos('P6') > pos('Raw3'))
        self.assertTrue(pos('P5') > pos('Raw3'))
        self.assertTrue(pos('P5') > pos('Raw4'))
        self.assertTrue(pos('P4') > pos('Raw1'))
        self.assertTrue(pos('P4') > pos('Raw2'))
        self.assertFalse('Floating' in order)
        self.assertFalse('root' in order)  #don't include the root!
コード例 #3
0
    def test_dependency_with_lowlevel_dependencies_requested(self):
        """ Simulate requesting a Raw Parameter as a dependency. This requires
        the requested node to be removed when it is not at the top of the
        dependency tree.
        """
        requested = ["P7", "P8", "P4", "P5", "P6", "Raw3"]  # top level nodes  # middle level node  # bottom level node
        mgr = NodeManager(
            {"Start Datetime": datetime.now()},
            10,
            self.lfl_params + ["Floating"],
            requested,
            [],
            self.derived_nodes,
            {},
            {},
        )
        gr = graph_nodes(mgr)
        gr_all, gr_st, order = process_order(gr, mgr)

        self.assertEqual(len(gr_st), 11)
        pos = order.index
        self.assertTrue(pos("P8") > pos("Raw5"))
        self.assertTrue(pos("P7") > pos("P4"))
        self.assertTrue(pos("P7") > pos("P5"))
        self.assertTrue(pos("P7") > pos("P6"))
        self.assertTrue(pos("P6") > pos("Raw3"))
        self.assertTrue(pos("P5") > pos("Raw3"))
        self.assertTrue(pos("P5") > pos("Raw4"))
        self.assertTrue(pos("P4") > pos("Raw1"))
        self.assertTrue(pos("P4") > pos("Raw2"))
        self.assertFalse("Floating" in order)
        self.assertFalse("root" in order)  # don't include the root!
コード例 #4
0
 def test_required_available(self):
     nodes = ["a", "b", "c"]
     required = ["a", "c"]
     mgr = NodeManager({"Start Datetime": datetime.now()}, 10, nodes, nodes, required, {}, {}, {})
     _graph = graph_nodes(mgr)
     gr_all, gr_st, order = process_order(_graph, mgr)
     self.assertEqual(set(required) - set(order), set())
コード例 #5
0
 def test_required_available(self):
     nodes = ['a', 'b', 'c']
     required = ['a', 'c']
     mgr = NodeManager(datetime.now(), 10, nodes, nodes, required, {}, {},
                       {})
     _graph = graph_nodes(mgr)
     gr_all, gr_st, order = process_order(_graph, mgr)
     self.assertEqual(set(required) - set(order), set())
コード例 #6
0
 def test_required_available(self):
     nodes = ['a', 'b', 'c']
     required = ['a', 'c']
     mgr = NodeManager(datetime.now(), 10, nodes, nodes, required, {}, {},
                       {})
     _graph = graph_nodes(mgr)
     gr_all, gr_st, order = process_order(_graph, mgr)
     self.assertEqual(set(required) - set(order), set())
コード例 #7
0
    def _generate_json(self, lfl_params):
        '''
        Returns list of parameters used in the spanning tree.

        Note: LFL parameters not used will not be returned!
        '''
        print "Establishing Node dependencies from Analysis Engine"
        # Ensure file is a valid HDF file before continuing:
        derived_nodes = get_derived_nodes(settings.NODE_MODULES)
        required_params = derived_nodes.keys()

        # TODO: Update ac_info with keys from provided fields:
        ac_info = {
            'Family': u'B737 NG',
            'Frame': u'737-3C',
            'Identifier': u'15',
            'Main Gear To Lowest Point Of Tail': None,
            'Main Gear To Radio Altimeter Antenna': None,
            'Manufacturer Serial Number': u'39009',
            'Manufacturer': u'Boeing',
            'Model': u'B737-8JP',
            'Precise Positioning': True,
            'Series': u'B737-800',
            'Tail Number': 'G-ABCD',
        }

        # TODO: Option to populate an AFR:
        achieved_flight_record = {}

        # Generate the dependency tree:
        node_mgr = NodeManager(
            {},
            1000,
            lfl_params,
            required_params,
            [],
            derived_nodes,
            ac_info,
            achieved_flight_record,
        )
        _graph = graph_nodes(node_mgr)
        gr_all, gr_st, order = process_order(_graph, node_mgr)

        # Save the dependency tree to tree.json:
        tree = os.path.join(AJAX_DIR, 'tree.json')
        with open(tree, 'w') as fh:
            json.dump(graph_adjacencies(gr_st), fh, indent=4)

        # Save the list of nodes to node_list.json:
        node_list = os.path.join(AJAX_DIR, 'node_list.json')
        spanning_tree_params = sorted(gr_st.nodes())
        with open(node_list, 'w') as fh:
            json.dump(spanning_tree_params, fh, indent=4)
        return
コード例 #8
0
    def _generate_json(self, lfl_params):
        '''
        Returns list of parameters used in the spanning tree.

        Note: LFL parameters not used will not be returned!
        '''
        print "Establishing Node dependencies from Analysis Engine"
        # Ensure file is a valid HDF file before continuing:
        derived_nodes = get_derived_nodes(settings.NODE_MODULES)
        required_params = derived_nodes.keys()

        # TODO: Update ac_info with keys from provided fields:
        ac_info = {
            'Family': u'B737 NG',
            'Frame': u'737-3C',
            'Identifier': u'15',
            'Main Gear To Lowest Point Of Tail': None,
            'Main Gear To Radio Altimeter Antenna': None,
            'Manufacturer Serial Number': u'39009',
            'Manufacturer': u'Boeing',
            'Model': u'B737-8JP',
            'Precise Positioning': True,
            'Series': u'B737-800',
            'Tail Number': 'G-ABCD',
        }

        # TODO: Option to populate an AFR:
        achieved_flight_record = {}

        # Generate the dependency tree:
        node_mgr = NodeManager(
            {},
            1000,
            lfl_params,
            required_params,
            [],
            derived_nodes,
            ac_info,
            achieved_flight_record,
        )
        _graph = graph_nodes(node_mgr)
        gr_all, gr_st, order = process_order(_graph, node_mgr)

        # Save the dependency tree to tree.json:
        tree = os.path.join(AJAX_DIR, 'tree.json')
        with open(tree, 'w') as fh:
            json.dump(graph_adjacencies(gr_st), fh, indent=4)

        # Save the list of nodes to node_list.json:
        node_list = os.path.join(AJAX_DIR, 'node_list.json')
        spanning_tree_params = sorted(gr_st.nodes())
        with open(node_list, 'w') as fh:
            json.dump(spanning_tree_params, fh, indent=4)
        return
コード例 #9
0
    def test_dependency(self):
        requested = ['P7', 'P8']
        mgr = NodeManager(datetime.now(), 10, self.lfl_params, requested, [],
                          self.derived_nodes, {}, {})
        gr = graph_nodes(mgr)
        gr_all, gr_st, order = process_order(gr, mgr)

        self.assertEqual(len(gr_st), 11)
        pos = order.index
        self.assertTrue(pos('P8') > pos('Raw5'))
        self.assertTrue(pos('P7') > pos('P4'))
        self.assertTrue(pos('P7') > pos('P5'))
        self.assertTrue(pos('P7') > pos('P6'))
        self.assertTrue(pos('P6') > pos('Raw3'))
        self.assertTrue(pos('P5') > pos('Raw3'))
        self.assertTrue(pos('P5') > pos('Raw4'))
        self.assertTrue(pos('P4') > pos('Raw1'))
        self.assertTrue(pos('P4') > pos('Raw2'))
        self.assertFalse('root' in order)  #don't include the root!
        """
コード例 #10
0
 def test_dependency(self):
     requested = ['P7', 'P8']
     mgr = NodeManager({'Start Datetime': datetime.now()}, 10, self.lfl_params, requested, [],
                       self.derived_nodes, {}, {})
     gr = graph_nodes(mgr)
     gr_all, gr_st, order = process_order(gr, mgr)
     
     self.assertEqual(len(gr_st), 11)
     pos = order.index
     self.assertTrue(pos('P8') > pos('Raw5'))
     self.assertTrue(pos('P7') > pos('P4'))
     self.assertTrue(pos('P7') > pos('P5'))
     self.assertTrue(pos('P7') > pos('P6'))
     self.assertTrue(pos('P6') > pos('Raw3'))
     self.assertTrue(pos('P5') > pos('Raw3'))
     self.assertTrue(pos('P5') > pos('Raw4'))
     self.assertTrue(pos('P4') > pos('Raw1'))
     self.assertTrue(pos('P4') > pos('Raw2'))
     self.assertFalse('root' in order) #don't include the root!
     
     """
コード例 #11
0
    def test_dependency(self):
        requested = ["P7", "P8"]
        mgr = NodeManager(
            {"Start Datetime": datetime.now()}, 10, self.lfl_params, requested, [], self.derived_nodes, {}, {}
        )
        gr = graph_nodes(mgr)
        gr_all, gr_st, order = process_order(gr, mgr)

        self.assertEqual(len(gr_st), 11)
        pos = order.index
        self.assertTrue(pos("P8") > pos("Raw5"))
        self.assertTrue(pos("P7") > pos("P4"))
        self.assertTrue(pos("P7") > pos("P5"))
        self.assertTrue(pos("P7") > pos("P6"))
        self.assertTrue(pos("P6") > pos("Raw3"))
        self.assertTrue(pos("P5") > pos("Raw3"))
        self.assertTrue(pos("P5") > pos("Raw4"))
        self.assertTrue(pos("P4") > pos("Raw1"))
        self.assertTrue(pos("P4") > pos("Raw2"))
        self.assertFalse("root" in order)  # don't include the root!

        """