Skip to content

Commit

Permalink
Merge pull request #379 from UCL-CCS/fix_ndarray_qois
Browse files Browse the repository at this point in the history
Fix ndarray qois in pce_analysis
  • Loading branch information
DavidPCoster authored Dec 4, 2024
2 parents d607845 + 8b23495 commit 309d897
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
25 changes: 20 additions & 5 deletions easyvvuq/analysis/pce_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,30 @@ def _describe(self, qoi, statistic):
return np.array([v.upper[0] for _, v in enumerate(
self.raw_data['output_distributions'][qoi])])
elif statistic == '1%':
return self.raw_data['percentiles'][qoi]['p01']
if isinstance(self.raw_data['percentiles'][qoi]['p01'], np.ndarray):
return self.raw_data['percentiles'][qoi]['p01']
else:
return np.array([self.raw_data['percentiles'][qoi]['p01']])
elif statistic == '10%':
return self.raw_data['percentiles'][qoi]['p10']
if isinstance(self.raw_data['percentiles'][qoi]['p10'], np.ndarray):
return self.raw_data['percentiles'][qoi]['p10']
else:
return np.array([self.raw_data['percentiles'][qoi]['p10']])
elif statistic == '90%':
return self.raw_data['percentiles'][qoi]['p90']
if isinstance(self.raw_data['percentiles'][qoi]['p90'], np.ndarray):
return self.raw_data['percentiles'][qoi]['p90']
else:
return np.array([self.raw_data['percentiles'][qoi]['p90']])
elif statistic == '99%':
return self.raw_data['percentiles'][qoi]['p99']
if isinstance(self.raw_data['percentiles'][qoi]['p99'], np.ndarray):
return self.raw_data['percentiles'][qoi]['p99']
else:
return np.array([self.raw_data['percentiles'][qoi]['p99']])
elif statistic == 'median':
return self.raw_data['percentiles'][qoi]['p50']
if isinstance(self.raw_data['percentiles'][qoi]['p50'], np.ndarray):
return self.raw_data['percentiles'][qoi]['p50']
else:
return np.array([self.raw_data['percentiles'][qoi]['p50']])
else:
try:
return self.raw_data['statistical_moments'][qoi][statistic]
Expand Down
5 changes: 3 additions & 2 deletions easyvvuq/analysis/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,9 @@ def plot_moments(
self.describe(qoi, 'std'), self.describe(qoi, 'mean') +
self.describe(qoi, 'std'), label='std', alpha=alpha)
ax.plot(xvalues, self.describe(qoi, 'mean'), label='mean')
ax.plot(xvalues, self.describe(qoi, '1%'), '--', label='1%', color='black')
ax.plot(xvalues, self.describe(qoi, '99%'), '--', label='99%', color='black')
if all(v in self.supported_stats() for v in ['1%', '99%']):
ax.plot(xvalues, self.describe(qoi, '1%'), '--', label='1%', color='black')
ax.plot(xvalues, self.describe(qoi, '99%'), '--', label='99%', color='black')
ax.grid(True)
if ylabel is None:
ax.set_ylabel(qoi)
Expand Down

0 comments on commit 309d897

Please sign in to comment.