# GNU General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with OpenQuake. If not, see <http://www.gnu.org/licenses/>. import os import unittest import numpy from risklib import api from risklib import scientific from risklib.tests.utils import vectors_from_csv THISDIR = os.path.dirname(__file__) gmv = vectors_from_csv('gmv', THISDIR) def vf(loss_ratios, covs=(0.0, 0.0, 0.0, 0.0, 0.0), taxonomy="T"): return scientific.VulnerabilityFunction( [0.1, 0.2, 0.3, 0.5, 0.7], loss_ratios, covs, "LN", taxonomy) class ScenarioRiskTestCase(unittest.TestCase): vulnerability_model_mean = dict( RM=vf([0.05, 0.1, 0.2, 0.4, 0.8], taxonomy="RM"), RC=vf([0.035, 0.07, 0.14, 0.28, 0.56], taxonomy="RC") ) hazard_mean = dict(
import os import collections import unittest import numpy from risklib import api from risklib import scientific from risklib.tests.utils import vectors_from_csv #: The conditional loss poes used for testing CONDITIONAL_LOSS_POES = 0.50 THISDIR = os.path.dirname(__file__) gmf = vectors_from_csv('gmf', THISDIR) gmf_bd = vectors_from_csv('gmf_bd', THISDIR) Triplet = collections.namedtuple('Triplet', 'a1 a2 a3') TestData = collections.namedtuple( 'TestData', 'input_models_asset expected_poes expected_losses ' 'expected_loss_map') mean_based_loss_curve_poes = [ 1.0, 1.0, 0.992492256, 0.9849845130, 0.9774767690, 0.9699690250, 0.962461282, 0.954953538, 0.947445794, 0.939938051, 0.932430307, 0.924922563, 0.917414819, 0.909907076, 0.902399332, 0.894891588, 0.887383845, 0.879876101, 0.872368357, 0.864860614, 0.857352870, 0.849845126, 0.842337382, 0.834829639, 0.827321895, 0.819814151, 0.812306408, 0.804798664, 0.79729092, 0.789783177, 0.7822754330,