<s> from __future__ import division <EOL> import sys <EOL> from nose . tools import with_setup <EOL> from numpy . testing import assert_allclose <EOL> from SALib . analyze import delta <EOL> from SALib . analyze import dgsm <EOL> from SALib . analyze import fast <EOL> from SALib . analyze import sobol <EOL> from SALib . sample import fast_sampler <EOL> from SALib . sample import finite_diff <EOL> from SALib . sample import latin <EOL> from SALib . sample import saltelli <EOL> import numpy as np <EOL> from . . analyze import morris <EOL> from . . sample . morris import sample <EOL> from . . test_functions import Ishigami <EOL> from . . util import read_param_file <EOL> from . test_util import teardown <EOL> def test_regression_morris_vanilla ( ) : <EOL> param_file = '<STR_LIT>' <EOL> problem = read_param_file ( param_file ) <EOL> param_values = sample ( problem = problem , N = <NUM_LIT> , num_levels = <NUM_LIT:10> , grid_jump = <NUM_LIT:5> , optimal_trajectories = None ) <EOL> Y = Ishigami . evaluate ( param_values ) <EOL> Si = morris . analyze ( problem , param_values , Y , <EOL> conf_level = <NUM_LIT> , print_to_console = False , <EOL> num_levels = <NUM_LIT:10> , grid_jump = <NUM_LIT:5> ) <EOL> assert_allclose ( Si [ '<STR_LIT>' ] , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT:0> , rtol = <NUM_LIT> ) <EOL> def test_regression_morris_groups ( ) : <EOL> param_file = '<STR_LIT>' <EOL> problem = read_param_file ( param_file ) <EOL> param_values = sample ( problem = problem , N = <NUM_LIT> , num_levels = <NUM_LIT:10> , grid_jump = <NUM_LIT:5> , optimal_trajectories = None ) <EOL> Y = Ishigami . evaluate ( param_values ) <EOL> Si = morris . analyze ( problem , param_values , Y , <EOL> conf_level = <NUM_LIT> , print_to_console = False , <EOL> num_levels = <NUM_LIT:10> , grid_jump = <NUM_LIT:5> ) <EOL> assert_allclose ( Si [ '<STR_LIT>' ] , [ <NUM_LIT> , <NUM_LIT> ] , rtol = <NUM_LIT> ) <EOL> def test_regression_morris_optimal ( ) : <EOL> '''<STR_LIT>''' <EOL> param_file = '<STR_LIT>' <EOL> problem = read_param_file ( param_file ) <EOL> param_values = sample ( problem = problem , N = <NUM_LIT:20> , num_levels = <NUM_LIT:4> , grid_jump = <NUM_LIT:2> , optimal_trajectories = <NUM_LIT:9> ) <EOL> Y = Ishigami . evaluate ( param_values ) <EOL> Si = morris . analyze ( problem , param_values , Y , <EOL> conf_level = <NUM_LIT> , print_to_console = False , <EOL> num_levels = <NUM_LIT:4> , grid_jump = <NUM_LIT:2> ) <EOL> assert_allclose ( Si [ '<STR_LIT>' ] , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , rtol = <NUM_LIT:10> ) <EOL> def test_regression_sobol ( ) : <EOL> param_file = '<STR_LIT>' <EOL> problem = read_param_file ( param_file ) <EOL> param_values = saltelli . sample ( problem , <NUM_LIT> , calc_second_order = True ) <EOL> Y = Ishigami . evaluate ( param_values ) <EOL> Si = sobol . analyze ( problem , Y , <EOL> calc_second_order = True , conf_level = <NUM_LIT> , print_to_console = False ) <EOL> assert_allclose ( Si [ '<STR_LIT>' ] , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT> , rtol = <NUM_LIT> ) <EOL> assert_allclose ( Si [ '<STR_LIT>' ] , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT> , rtol = <NUM_LIT> ) <EOL> assert_allclose ( [ Si [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , Si [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:2> ] , Si [ '<STR_LIT>' ] [ <NUM_LIT:1> ] [ <NUM_LIT:2> ] ] , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT> , rtol = <NUM_LIT> ) <EOL> def test_regression_sobol_parallel ( ) : <EOL> param_file = '<STR_LIT>' <EOL> problem = read_param_file ( param_file ) <EOL> param_values = saltelli . sample ( problem , <NUM_LIT> , calc_second_order = True ) <EOL> Y = Ishigami . evaluate ( param_values ) <EOL> Si = sobol . analyze ( problem , Y , <EOL> calc_second_order = True , parallel = True , conf_level = <NUM_LIT> , print_to_console = False ) <EOL> assert_allclose ( Si [ '<STR_LIT>' ] , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT> , rtol = <NUM_LIT> ) <EOL> assert_allclose ( Si [ '<STR_LIT>' ] , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT> , rtol = <NUM_LIT> ) <EOL> assert_allclose ( [ Si [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , Si [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:2> ] , Si [ '<STR_LIT>' ] [ <NUM_LIT:1> ] [ <NUM_LIT:2> ] ] , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT> , rtol = <NUM_LIT> ) <EOL> def test_regression_sobol_groups ( ) : <EOL> problem = { <EOL> '<STR_LIT>' : <NUM_LIT:3> , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ [ - np . pi , np . pi ] ] * <NUM_LIT:3> , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> } <EOL> param_values = saltelli . sample ( problem , <NUM_LIT> , calc_second_order = True ) <EOL> Y = Ishigami . evaluate ( param_values ) <EOL> Si = sobol . analyze ( problem , Y , <EOL> calc_second_order = True , parallel = True , conf_level = <NUM_LIT> , print_to_console = False ) <EOL> assert_allclose ( Si [ '<STR_LIT>' ] , [ <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT> , rtol = <NUM_LIT> ) <EOL> assert_allclose ( Si [ '<STR_LIT>' ] , [ <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT> , rtol = <NUM_LIT> ) <EOL> assert_allclose ( Si [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , [ <NUM_LIT> ] , atol = <NUM_LIT> , rtol = <NUM_LIT> ) <EOL> def test_regression_sobol_groups_dists ( ) : <EOL> problem = { <EOL> '<STR_LIT>' : <NUM_LIT:3> , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ [ - np . pi , np . pi ] , [ <NUM_LIT:1.0> , <NUM_LIT> ] , [ <NUM_LIT:3> , <NUM_LIT:0.5> ] ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> } <EOL> param_values = saltelli . sample ( problem , <NUM_LIT> , calc_second_order = True ) <EOL> Y = Ishigami . evaluate ( param_values ) <EOL> Si = sobol . analyze ( problem , Y , <EOL> calc_second_order = True , parallel = True , conf_level = <NUM_LIT> , print_to_console = False ) <EOL> assert_allclose ( Si [ '<STR_LIT>' ] , [ <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT> , rtol = <NUM_LIT> ) <EOL> assert_allclose ( Si [ '<STR_LIT>' ] , [ <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT> , rtol = <NUM_LIT> ) <EOL> assert_allclose ( Si [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , [ <NUM_LIT> ] , atol = <NUM_LIT> , rtol = <NUM_LIT> ) <EOL> def test_regression_fast ( ) : <EOL> param_file = '<STR_LIT>' <EOL> problem = read_param_file ( param_file ) <EOL> param_values = fast_sampler . sample ( problem , <NUM_LIT> ) <EOL> Y = Ishigami . evaluate ( param_values ) <EOL> Si = fast . analyze ( problem , Y , print_to_console = False ) <EOL> assert_allclose ( Si [ '<STR_LIT>' ] , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT> , rtol = <NUM_LIT> ) <EOL> assert_allclose ( Si [ '<STR_LIT>' ] , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT> , rtol = <NUM_LIT> ) <EOL> def test_regression_dgsm ( ) : <EOL> param_file = '<STR_LIT>' <EOL> problem = read_param_file ( param_file ) <EOL> param_values = finite_diff . sample ( problem , <NUM_LIT> , delta = <NUM_LIT> ) <EOL> Y = Ishigami . evaluate ( param_values ) <EOL> Si = dgsm . analyze ( problem , param_values , Y , <EOL> conf_level = <NUM_LIT> , print_to_console = False ) <EOL> assert_allclose ( Si [ '<STR_LIT>' ] , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT> , rtol = <NUM_LIT> ) <EOL> def test_regression_delta ( ) : <EOL> param_file = '<STR_LIT>' <EOL> problem = read_param_file ( param_file ) <EOL> param_values = latin . sample ( problem , <NUM_LIT> ) <EOL> Y = Ishigami . evaluate ( param_values ) <EOL> Si = delta . analyze ( problem , param_values , Y , <EOL> num_resamples = <NUM_LIT:10> , conf_level = <NUM_LIT> , print_to_console = True ) <EOL> assert_allclose ( Si [ '<STR_LIT>' ] , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT> , rtol = <NUM_LIT> ) <EOL> assert_allclose ( Si [ '<STR_LIT>' ] , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , atol = <NUM_LIT> , rtol = <NUM_LIT> ) </s>
