def test_get_mmax(self):
        '''
        Tests the function to get Mmax
        Values come from WC1994 (tested in openquake.hazardlib) - only 
        functionality is tested for here!
        '''
        # Case 1 MMmax and uncertainty specified in config
        self.config['Maximum_Magnitude'] = 8.0
        self.config['Maximum_Magnitude_Uncertainty'] = 0.2

        self.model = AndersonLucoArbitrary()
        self.model.setUp(self.config)
        self.model.get_mmax(self.config, self.msr, 0., 8500.)
        self.assertAlmostEqual(self.model.mmax, 8.0)
        self.assertAlmostEqual(self.model.mmax_sigma, 0.2)

        # Case 2: Mmax and uncertainty not specified in config
        self.config['Maximum_Magnitude'] = None
        self.config['Maximum_Magnitude_Uncertainty'] = None

        self.model = AndersonLucoArbitrary()
        self.model.setUp(self.config)
        self.model.get_mmax(self.config, self.msr, 0., 8500.)
        self.assertAlmostEqual(self.model.mmax, 7.9880073)
        self.assertAlmostEqual(self.model.mmax_sigma, 0.23)
    def test_get_mfd(self):
        '''
        Tests the function to get magnitude frequency distribution
        '''
        self.msr = WC1994()

        # Test 1: For a fault with 20 mm/yr slip, and an area of 30000 km ** 2
        self.msr = WC1994()
        # Testing all three calculators!
        for iloc, model_type in enumerate(['First', 'Second', 'Third']):
            self.model = AndersonLucoArbitrary()

            self.config = {
                'Model_Type': model_type,
                'MFD_spacing': 0.1,
                'Model_Weight': 1.0,
                'Minimum_Magnitude': 5.0,
                'Maximum_Magnitude': None,
                'b_value': [1.0, 0.1]
            }
            self.model.setUp(self.config)
            self.model.get_mmax(self.config, self.msr, 0., 30000.)
            test_output = self.model.get_mfd(20., 30000.)
            print AL83_INC_DATA[:, iloc], test_output[2]
            np.testing.assert_array_almost_equal(AL83_INC_DATA[:, iloc],
                                                 test_output[2])

            # Test case when b-value greater than d-value (raises warning!)
            self.model = AndersonLucoArbitrary()

            self.config = {
                'Model_Type': model_type,
                'MFD_spacing': 0.1,
                'Model_Weight': 1.0,
                'Minimum_Magnitude': 5.0,
                'Maximum_Magnitude': None,
                'b_value': [2.0, 0.1]
            }
            self.model.setUp(self.config)
            self.model.get_mmax(self.config, self.msr, 0., 30000.)
            self.model.get_mfd(20., 30000.)
            self.assertTrue(np.all(np.isnan(self.model.occurrence_rate)))
    def setUp(self):
        self.model = AndersonLucoArbitrary()
        self.config = {
            'Model_Type': 'First',
            'MFD_spacing': 0.1,
            'Model_Weight': 1.0,
            'Minimum_Magnitude': 5.0,
            'Maximum_Magnitude': None,
            'b_value': [1.0, 0.1]
        }

        self.msr = WC1994()