Exemple #1
0
    def test_check_completeness_table_numpy_array(self):
        '''
        Tests behaviour when data input as numpy array
        '''
        # When valid data is input
        simple_array = np.array([[1990., 4.0], [1960., 5.0]])
        np.testing.assert_array_almost_equal(
            simple_array, utils.check_completeness_table(simple_array, None))
        # When invalid data is input
        bad_array = np.array([[1990., 4.0, 23.4], [1960., 5.0, 2.1]])

        with self.assertRaises(AssertionError) as aer:
            utils.check_completeness_table(bad_array, None)
    def test_check_completeness_table_list(self):
        '''
        Tests behaviour when data input as two-element list
        '''
        # When valid data is input
        simple_list = [1990., 4.0]
        np.testing.assert_array_almost_equal(np.array([simple_list]),
                             utils.check_completeness_table(simple_list, None))
        # When invalid data is input
        bad_list = [1990.]

        with self.assertRaises(AssertionError) as aer:
            utils.check_completeness_table(bad_list, None)
Exemple #3
0
    def test_check_completeness_table_list(self):
        '''
        Tests behaviour when data input as two-element list
        '''
        # When valid data is input
        simple_list = [1990., 4.0]
        np.testing.assert_array_almost_equal(
            np.array([simple_list]),
            utils.check_completeness_table(simple_list, None))
        # When invalid data is input
        bad_list = [1990.]

        with self.assertRaises(AssertionError) as aer:
            utils.check_completeness_table(bad_list, None)
    def test_check_completeness_table_numpy_array(self):
        '''
        Tests behaviour when data input as numpy array
        '''
        # When valid data is input
        simple_array = np.array([[1990., 4.0],
                                 [1960., 5.0]])
        np.testing.assert_array_almost_equal(
            simple_array, utils.check_completeness_table(simple_array, None))
        # When invalid data is input
        bad_array = np.array([[1990., 4.0, 23.4],
                               [1960., 5.0, 2.1]])

        with self.assertRaises(AssertionError) as aer:
            utils.check_completeness_table(bad_array, None)
 def test_check_completeness_table_none(self):
     '''
     Checks any other instance - completeness from catalogue
     '''
     self.catalogue.data['year'] = np.array([1991., 1992., 1990., 2005.])
     self.catalogue.data['magnitude'] = np.array([4.1, 4.5, 4.0, 7.5])
     np.testing.assert_array_almost_equal(np.array([[1990., 4.0]]),
         utils.check_completeness_table(None, self.catalogue))
Exemple #6
0
 def test_check_completeness_table_none(self):
     '''
     Checks any other instance - completeness from catalogue
     '''
     self.catalogue.data['year'] = np.array([1991., 1992., 1990., 2005.])
     self.catalogue.data['magnitude'] = np.array([4.1, 4.5, 4.0, 7.5])
     np.testing.assert_array_almost_equal(
         np.array([[1990., 4.0]]),
         utils.check_completeness_table(None, self.catalogue))