Skip to content

Commit

Permalink
Merge pull request SALib#636 from Zapiano/bug_635
Browse files Browse the repository at this point in the history
Fix pawn analysis for problems with groups
  • Loading branch information
ConnectedSystems authored Sep 9, 2024
2 parents 6fb0a9c + a3e0f4d commit 1305f85
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/SALib/analyze/pawn.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,9 @@ def analyze(

# Take the mean of effects from parameters that are grouped together
unique_grps = np.array(unique_grps)
grps = np.array(groups)
for grp_id, grp in enumerate(unique_grps):
tmp[grp_id, :] = np.mean(results[unique_grps == grp, :], axis=0)
tmp[grp_id, :] = np.mean(results[grps == grp, :], axis=0)

results = tmp
tmp = None
Expand Down
10 changes: 10 additions & 0 deletions tests/test_analyze_pawn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from SALib.util import read_param_file
from SALib import ProblemSpec
from SALib.test_functions import Ishigami


def test_analyze_pawn():
param_file = "src/SALib/test_functions/params/Ishigami_groups.txt"
problem = read_param_file(param_file)
sp = ProblemSpec(problem)
sp.sample_sobol(512).evaluate(Ishigami.evaluate).analyze_pawn()

0 comments on commit 1305f85

Please sign in to comment.