コード例 #1
0
 def test_derive_basic(self):
     flight_number_param = P('Flight Number',
                             array=np.ma.masked_array([103, 102,102]))
     flight_number = FlightNumber()
     flight_number.set_flight_attr = Mock()
     flight_number.derive(flight_number_param)
     flight_number.set_flight_attr.assert_called_with('102')
コード例 #2
0
 def test_derive_masked(self):
     '''
     
     '''
     flight_number = FlightNumber()
     number_param = P(
         'Flight Number',
         array=np.ma.array([0, 0, 0, 0, 36, 36, 0, 0, 0, 0],
                           mask=[True] * 4 + [False] * 2 + [True] * 4))
     flight_number.derive(number_param)
     self.assertEqual(flight_number.value, '36')
コード例 #3
0
 def test_derive_ascii(self):
     flight_number_param = P('Flight Number',
                             array=np.ma.masked_array(['ABC', 'DEF', 'DEF'],
                                                      dtype=np.string_))
     flight_number = FlightNumber()
     flight_number.set_flight_attr = Mock()
     flight_number.derive(flight_number_param)
     flight_number.set_flight_attr.assert_called_with('DEF')
     flight_number.set_flight_attr.reset_mock()
     # Entirely masked.
     flight_number_param.array[:] = np.ma.masked
     flight_number.derive(flight_number_param)
     flight_number.set_flight_attr.called = False
コード例 #4
0
 def test_derive_ascii(self):
     flight_number_param = P('Flight Number',
                             array=np.ma.masked_array(['ABC', 'DEF', 'DEF']))
     flight_number = FlightNumber()
     flight_number.set_flight_attr = Mock()
     flight_number.derive(flight_number_param)
     flight_number.set_flight_attr.assert_called_with('DEF')
     flight_number.set_flight_attr.reset_mock()
     # Entirely masked.
     flight_number_param.array[:] = np.ma.masked
     flight_number.derive(flight_number_param)
     flight_number.set_flight_attr.called = False
コード例 #5
0
    def test_derive_most_common_positive_float(self):
        flight_number = FlightNumber()

        neg_number_param = P(
            'Flight Number',
            array=np.ma.array([-1,2,-4,10,20,40,11]))
        flight_number.derive(neg_number_param)
        self.assertEqual(flight_number.value, None)

        # TODO: Implement variance checks as below
        ##high_variance_number_param = P(
            ##'Flight Number',
            ##array=np.ma.array([2,2,4,4,4,7,7,7,4,5,4,7,910]))
        ##self.assertRaises(ValueError, flight_number.derive, high_variance_number_param)

        flight_number_param= P(
            'Flight Number',
            array=np.ma.array([2,555.6,444,444,444,444,444,444,888,444,444,
                               444,444,444,444,444,444,7777,9100]))
        flight_number.set_flight_attr = Mock()
        flight_number.derive(flight_number_param)
        flight_number.set_flight_attr.assert_called_with('444')
コード例 #6
0
 def test_derive(self):
     flight_number = load(os.path.join(test_data_path,
                                       'FDRFlightNumber_FlightNumber.nod'))
     node = FlightNumber()
     node.derive(flight_number)
     self.assertEqual(node.value, '805')
コード例 #7
0
 def test_can_operate(self):
     self.assertEqual(FlightNumber.get_operational_combinations(),
                      [('Flight Number',)])